配置VScode终端
终端管理
设置更改选项卡位置
使用terminal.integrated.tabs.location设置更改选项卡位置
"terminal.integrated.tabs.location" :"right"
拆分终端
通过以下方式拆分终端:
- 在悬停时,选择内联拆分按钮。
- 右键单击上下文菜单并选择拆分菜单选项。
- Alt单击选项卡、+按钮或终端面板上的单个选项卡。
- 使用Ctrl+Shift+5命令。
自定义标签
通过右键单击上下文菜单或触发以下命令来更改终端的名称、图标和选项卡颜色:
终端:重命名 workbench.action.terminal.rename
终端:更改图标 workbench.action.terminal.changeIcon
终端:改变颜色 workbench.action.terminal.changeColor
终端配置文件
终端配置文件是特定于平台的 shell 配置,由可执行路径、参数和其他自定义组成。
示例配置文件:
{
"terminal.integrated.profiles.windows": {
"My PowerShell": {
"path": "pwsh.exe",
"args": ["-noexit", "-file", "${env:APPDATA}PowerShellmy-init-script.ps1"]
}
},
"terminal.integrated.defaultProfile.windows": "My PowerShell"
}
您可以在终端配置文件中使用变量,如上面示例中所示,以及APPDATA环境变量。您可以在变量参考主题中找到可用变量的列表。
通过运行终端配置您的默认集成终端:选择默认配置文件命令,该命令也可通过终端下拉菜单访问
终端的 shell在 Linux 和 macOS 上默认为$SHELL,Windows 上默认为 PowerShell。VS Code 将自动检测大多数标准 shell,然后可以将其配置为默认值。
配置配置文件
可以使用path或source以及一组可选参数创建配置文件。source仅适用于Windows,可以用来让VS代码检测安装的任何PowerShell或Git Bash。path可以使用直接指向 shell 可执行文件。以下是一些示例配置文件配置:
{
"terminal.integrated.profiles.windows": {
"PowerShell -NoProfile": {
"source": "PowerShell",
"args": ["-NoProfile"]
}
},
"terminal.integrated.profiles.linux": {
"zsh (login)": {
"path": "zsh",
"args": ["-l"]
}
}
}
配置文件中支持的其他参数包括:
- overrideName:一个布尔值,指示是否用静态配置文件名称替换检测正在运行的程序的动态终端标题。
- env: 定义环境变量及其值的映射,将变量设置null为将其从环境中删除。这可以使用terminal.integrated.env.设置为所有配置文件配置。
- icon:用于配置文件的图标 ID。
- color:用于设置图标样式的主题颜色 ID。
提示: path、args、env都支持解析变量
该默认配置文件可以手动与定义terminal.integrated.defaultProfile.*设置。这应该设置为现有配置文件的名称:
{
"terminal.integrated.profiles.windows": {
"my-pwsh": {
"source": "PowerShell",
"args": ["-NoProfile"]
}
},
"terminal.integrated.defaultProfile.windows": "my-pwsh"
}
提示:集成终端外壳在 VS Code 的权限下运行。如果您需要使用提升的(管理员)权限或不同的权限运行 shell 命令,请使用平台实用程序,例如runas.exe在终端中。
删除内置配置文件
要从终端下拉列表中删除条目,请将配置文件的名称设置为null。例如,要删除Git Bash Windows 上的配置文件,请使用以下设置:
{
"terminal.integrated.profiles.windows": {
"Git Bash": null
}
}
其他请阅读
修改settings.json文件
{
"KeilAssistant.MDK.Uv4Path": "E:\\keil\\??\\UV4\\UV4.exe",
"C_Cpp.updateChannel": "Insiders",
"files.autoGuessEncoding": true,
"http.proxySupport": "off",
"workbench.iconTheme": "material-icon-theme",
"cmake.configureOnOpen": true,
"workbench.editorAssociations": {
"*.ipynb": "jupyter-notebook"
},
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "left"
},
//"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
//"terminal.integrated.defaultProfile.windows": "Command Prompt",
//"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
//"path": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"color": "terminal.ansiBlue"
},
"gitBash": {
"path": "E:\\Git\\Git\\bin\\bash.exe",
"color": "terminal.ansiYellow"
},
"cmd": {
"path": "C:\\WINDOWS\\System32\\cmd.exe",
"color": "terminal.ansiRed",
"icon": "account",
//"workbench.action.terminal.changeColor":"terminal.ansiYellow"
}
},
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.tabs.location" :"right"
}
添加自定义背景图片
先在vscode里面下载扩展插件“background”,默认会有一张背景图,也可以自己定义
找到并打开打开settings.json
添加如下代码
//background 的相关配置
"update.enableWindowsBackgroundUpdates": true,
"background.customImages": [
//本地图片的位置,唯一需要改的地方
"E:\\vscode\\picture",
//"C:/Users/hp/Pictures/Camera Roll/2.jpg"
],
"background.style":
{
"content":"''",
"pointer-events":"none",
"position":"absolute",//图片位置
"width":"100%",
"height":"120%",
"z-index":"99999",
"background.repeat":"repeat-Y",
"background-size":"cover",//图片大小
"opacity": 0.2 //透明度
},
"background.useFront": true,
"background.useDefault": false,
"editor.fontSize": 21, //是否使用默认图片
settings.json代码
{
"KeilAssistant.MDK.Uv4Path": "E:\\keil\\??\\UV4\\UV4.exe",
"C_Cpp.updateChannel": "Insiders",
"files.autoGuessEncoding": true,
"http.proxySupport": "off",
"workbench.iconTheme": "material-icon-theme",
"cmake.configureOnOpen": true,
"workbench.editorAssociations": {
"*.ipynb": "jupyter-notebook"
},
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "left"
},
//"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
//"terminal.integrated.defaultProfile.windows": "Command Prompt",
//"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
//"path": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"color": "terminal.ansiBlue"
},
"gitBash": {
"path": "E:\\Git\\Git\\bin\\bash.exe",
"color": "terminal.ansiYellow"
},
"cmd": {
"path": "C:\\WINDOWS\\System32\\cmd.exe",
"color": "terminal.ansiRed",
"icon": "account",
//"workbench.action.terminal.changeColor":"terminal.ansiYellow"
}
},
"terminal.integrated.profiles.linux": {
"Ubuntu-bash": {
"path": "/bin/bash",
"color": "terminal.ansiGreen",
"icon": "thumbsup",
//"workbench.action.terminal.changeColor":"terminal.ansiYellow"
}
},
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.tabs.location": "right",
"terminal.integrated.defaultProfile.linux": "Ubuntu-bash",
//background 的相关配置
"update.enableWindowsBackgroundUpdates": true,
"background.customImages": [
//本地图片的位置,唯一需要改的地方
"E:\\vscode\\picture",
//"C:/Users/hp/Pictures/Camera Roll/2.jpg"
],
"background.style":
{
"content":"''",
"pointer-events":"none",
"position":"absolute",//图片位置
"width":"100%",
"height":"120%",
"z-index":"99999",
"background.repeat":"repeat-Y",
"background-size":"cover",//图片大小
"opacity": 0.2 //透明度
},
"background.useFront": true,
"background.useDefault": false,
"editor.fontSize": 21,
"bracketPairColorizer.depreciation-notice": false, //是否使用默认图片
}
报错:Code安装似乎损坏,请重新安装
接着上面的步骤,修改完重启vscode,直接给code玩坏了
此时需要安装Fix VSCode Checksums插件
Ctrl+Shift+P , 输入Fix Checksums:Apply(注意冒号是英文的),点击,重启即可,记住需要在本地打开(Windows上)的VSCode中搜索
在连接了WSL的VSCode中可能找不到Fix Checksums:Apply,或者会报错
重启后可以了,但是图片加载不出来,把图片路径修改如下
修改后保存重启就可以了,有一点不好就是每次修改后都会造成code损坏的报错,需要Ctrl+Shift+P,输入Fix Checksums :Apply,点击,重启
最后我想背景图全屏显示,于是修改settings.json
修改后的settings.json代码
{
"KeilAssistant.MDK.Uv4Path": "E:\\keil\\??\\UV4\\UV4.exe",
"C_Cpp.updateChannel": "Insiders",
"files.autoGuessEncoding": true,
"http.proxySupport": "off",
"workbench.iconTheme": "material-icon-theme",
"cmake.configureOnOpen": true,
"workbench.editorAssociations": {
"*.ipynb": "jupyter-notebook"
},
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "left"
},
//"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
//"terminal.integrated.defaultProfile.windows": "Command Prompt",
//"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
//"path": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"color": "terminal.ansiBlue"
},
"gitBash": {
"path": "E:\\Git\\Git\\bin\\bash.exe",
"color": "terminal.ansiYellow"
},
"cmd": {
"path": "C:\\WINDOWS\\System32\\cmd.exe",
"color": "terminal.ansiRed",
"icon": "account",
//"workbench.action.terminal.changeColor":"terminal.ansiYellow"
}
},
"terminal.integrated.profiles.linux": {
"Ubuntu-bash": {
"path": "/bin/bash",
"color": "terminal.ansiGreen",
"icon": "thumbsup",
//"workbench.action.terminal.changeColor":"terminal.ansiYellow"
}
},
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.tabs.location": "right",
"terminal.integrated.defaultProfile.linux": "Ubuntu-bash",
//"bracketPairColorizer.depreciation-notice": false,
//background 的相关配置
"update.enableWindowsBackgroundUpdates": true,
"background.customImages": [
//本地图片的位置,唯一需要改的地方
"file:///E:/vscode/picture/1.JPG",
//"C:/Users/hp/Pictures/Camera Roll/2.jpg"
],
"background.style":
{
"content":"''",
"pointer-events":"none",
"position":"fixed",//图片位置居中
"width":"100%",
"height":"120%",
"z-index":"99999",
"top":"0px",
"left":"0px",
"background.repeat":"no-repeat",
"background-size":"cover",//图片大小为全屏
"opacity": 0.2 //透明度
},
"background.useFront": true,
"background.useDefault": false,
//"editor.fontSize": 21,
"bracketPairColorizer.depreciation-notice": false, //是否使用默认图片
}
VScode运行代码显示:Code is already running
如果程序不会自动退出,而是显示代码一直运行,可以通过下面的解决方案退出程序:切换到OUTPUT(输出),点击tab,再点鼠标右键,然后选择stop code run