在vscode中編寫shell腳本非常方便,可以使用如下shell插件方便開發,調試。
1.shellman: 語法提示
2.shell-format: 格式化
3.shellcheck: 語法錯誤檢查
配置如下:
https://storage.googleapis.com/shellcheck/shellcheck-stable.zip 下載解壓後設置如下:
"shellcheck.executablePath": "D:\software\shellcheck-stable\shellcheck-stable.exe"
其他的調整隨自己喜歡即可。
4.Code Runner:本地運行shell
編寫shell腳本時在本地運行調試時需要使用git的bash,所以需要在第一行如下設置,否則亂碼輸出:
#!d:\software\Git\bin\bash
echo "hello world"
vscode設置bash與cmd共存
設置》搜索terminal 把原來的註釋,設置如下:
"terminal.integrated.shell.windows": "D:\\software\\Git\\bin\\bash.exe"
就可以在終端中通過輸入bash或cmd隨意切換了。