在 File → Preferences → Custom Commands 中,添加 Respository 命令。
#!/bin/bash# 已知的路径格式(Unix/Linux风格,其中/d表示D盘)
unix_path=$PWD# 提取盘符(注意:这里假设盘符总是小写,并且紧跟在根斜杠后面)
disk_letter="${unix_path:1:1}"
disk_letter=$(echo "$disk_letter" | tr '[:lower:]' '[:upper:]') # 转换为大写# 提取剩余路径部分
remaining_path="${unix_path#/*/}"# 将剩余路径部分的斜杠替换为Windows风格的反斜杠
windows_remaining_path="${remaining_path//\//\\}"# 组合盘符和剩余路径部分,形成Windows风格路径
windows_path="${disk_letter}:\\${windows_remaining_path}"# 输出转换后的Windows风格路径
echo "$windows_path"code $windows_path