在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随意切换了。