VSCode 設定自定義終端的注意事項
情境說明
當 Git Bash 沒有被 VSCode 自動偵測到時,可以透過手動新增設定檔來解決。但需要注意兩個關鍵細節,否則自訂設定會失效。
注意事項
1. 設定檔名稱不可為 Git Bash
VSCode 已內建名為 Git Bash 的終端設定檔,若自訂設定使用相同名稱,會導致衝突。建議使用其他名稱,例如 Git Bash (local)。
2. 必須移除 source 欄位
若有 source 欄位存在,VSCode 會優先使用內建定義來覆蓋自訂設定,導致自訂路徑無法被正確偵測。因此手動設定時必須刪除 source 欄位。
正確設定範例
將以下配置加入 VSCode 的 settings.json 中:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash (local)": {
"icon": "terminal-git-bash",
"path": [
"D:/msys64/bin/bash.exe",
"C:/Program Files/Git/bin/bash.exe"
]
}
}
常見問題
| 問題 | 原因 | 解決方式 |
|---|---|---|
| 自訂 Git Bash 無效 | 設定檔名稱使用了 Git Bash |
改用其他名稱(如 Git Bash (local)) |
| 路徑設定未生效 | 遺留了 source 欄位 |
移除 source 欄位,僅保留 path 與 icon |
沒有留言:
張貼留言