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"按钮


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”(根据自己的存放路径,并注意路径中斜杠方向)
备注:如果无法下载shfmt,也可使用在线格式化工具

https://tool.lu/shell/
http://web.chacuo.net/formatsh
 


2.5 安装Code Runner


简介

运行代码

搜索栏输入Code Runner,点击"install"按钮


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


进入Settings,输入"Code-runner:Run in Terminal",勾选"Whether to run code in Integrated Terminal."


3. 编写运行代码


直接运行会报错,需要在Terminal窗口输入"bash"。


切换为bash环境

前面介绍的插件都是美化和辅助你更好些编写shell脚本,Romote-SSH确是实现你远程Linux环境开发,真正提高效率的神器。
安装完插件后,编辑器界面或多出一个ssh模块,如下图:

紧接着我们要配置要远程的linux机器地址,点击配置按钮,选择第一个配置项

跳转到配置文件,配置参数如下:

远程Linux机器


附录一

资源                地址
高级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


参考文档:Visual Studio Code 配置Shell环境(第1次更新:20230416)_vscode运行sh_道格卡琳的博客-CSDN博客

Windows下Visual Studio Code配置Shell开发环境 (超详细图文)| 瞬间提高200%生产力_visio studio code怎么运行shell文件-CSDN博客

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐