1.前置
1.1 安装visual studio code(vscode)
下载地址:https://code.visualstudio.com/download
安装:略
1.2 安装git
下载地址:https://git-scm.com/downloads
安装:略
2. 安装插件
2.1 进入应用市场
打开vscode后,点击左侧的"extensions"扩展面板,并在搜索栏输入扩展插件的名字。

2.2 安装shellman
-
简介
智能提示和自动补全
-
搜索、安装插件
搜索栏输入shellman,点击"install"按钮

安装完毕

- 查看效果
点击"explorer"资源管理器面板,右键单击红框处,点击"new file"新建文件。

新建"shellmantest.sh"文件,输入case,显示代码提示。

选中第一个后,效果如下

2.3 安装shellcheck
-
简介
语法、错误检查
-
搜索、安装插件
搜索栏输入shellman,点击"install"按钮

安装完毕

- 查看效果

2.4 安装shell-format
-
简介
格式化代码
-
搜索、安装插件
搜索栏输入shell-format,点击"install"按钮

安装完毕

- 下载shfmt
网址:https://github.com/mvdan/sh/releases
点击“shfmt_v3.6.0_windows_amd64.exe”下载(可能需要科学上网才能下载)

- 存放文件
将下载的exe文件,存放到任意目录

- 配置
依次点击"file"——>“preferences”——>“settings”

进入settings,输入"shell-format",点击"edit in settings json"

将shfmt.exe的路径配置到shellformat.path中,并保存
“shellformat.path”: “d:/program files/shfmt/shfmt_v3.6.0_windows_amd64.exe”(根据自己的存放路径,并注意路径中斜杠方向)

- 查看效果
在代码的任意地方,单击鼠标右键,选择"format document"

效果如图

备注:如果无法下载shfmt,也可使用在线格式化工具
https://tool.lu/shell/
http://web.chacuo.net/formatsh
2.5 安装code runner
-
简介
运行代码
-
搜索、安装插件
搜索栏输入code runner,点击"install"按钮

安装完毕

- 配置环境变量
配置git的环境变量

进入settings,输入"code-runner:run in terminal",勾选"whether to run code in integrated terminal."

3. 编写运行代码
直接运行会报错,需要在terminal窗口输入"bash"。

切换为bash环境

再次运行,显示正常

附录一
| 资源 | 地址 |
|---|---|
| 高级bash脚本编程指南-英文原版 | https://tldp.org/ldp/abs/html/ |
| 高级bash脚本编程指南-中译本 | http://home.ustc.edu.cn/~stephen1/book/abs-guide-3.7-cn/html/index.html |
| 高级bash脚本编程指南-中译本最新 | https://linuxstory.gitbook.io/advanced-bash-scripting-guide-in-chinese/ |
| bash reference manual | https://www.gnu.org/software/bash/manual/bash.html |
| bash中文手册 | https://chegva.com/2777.html |
| 鸟哥的linux私房菜 | http://cn.linux.vbird.org/linux_basic/linux_basic.php |
参考
vscode: windows 下配置 vscode运行shell
工具
截图工具:fscapture 8.4
文档编写工具:typora
ps: 如果本文对您有帮助,请单击文章最后左下角的“点赞”或留言。
pps:本人水平有限,难免出现错误。如您发现错误,请批评指正。
发表评论