本文轉載自:王老師文章: VSCode設置bash處理
其他擴展知識文章:變量參考:https://code.visualstudio.com/docs/editor/variables-reference
VSCode插件:Command Variable
宏:https://baike.baidu.com/item/%E5%AE%8F/2648286
以下是正文:
VSCode設置bash處理
全局VS Code設置文件路徑:C:\Users\wyp\AppData\Roaming\Code\User\settings.json
vscode—修改默認的shell
1、修改默認的shell的方法步驟:
1. Ctrl + Shift + P : 調出命令輸入框
2. 輸入 Terminal: Select Default Shell

3. 輸入要使用的 shell 或者選擇也可,例如:

在C:\Users\wyp\AppData\Roaming\Code\User\settings.json文件里,設置 -l 參數,需要配置環境變量Path的值為bash所在的路徑,-l 表示登錄,可以獲取環境變量信息。
配置好終端使用shell之后,就可以測試一下linux命令了:

2、打開vscode 的設置git路徑:

輸入:git.p

這里面有一個git.path,設置 git.exe 文件所在的路徑,
"git.defaultCloneDirectory": "", "git.path": "C:\\Program Files\\Git\\bin\\git.exe"
最終設置之后的截圖:

3、每個項目具體的VS Code設置:例如:設置IDE字體大小
.vscode\settings.json 文件內容
{
"editor.fontFamily": "JetBrains Mono",
"editor.fontSize": 14,
"editor.fontLigatures": "true",
"editor.fontWeight": "normal",
"debug.console.fontFamily": "Fira Code,JetBrains Mono",
"scm.inputFontFamily": "Fira Code,JetBrains Mono",
"terminal.integrated.fontFamily": "Fira Code,JetBrains Mono",
"rest-client.fontFamily": "Fira Code,JetBrains Mono",
"rest-client.fontSize": 15,
"window.zoomLevel": 1.0,
"window.autoDetectColorScheme": true,
"workbench.colorTheme": "Night Owl (No Italics)",
"workbench.tree.indent": 16
}

4、安裝command-variable插件
設置執行.vscode\launch.json,.vscode\tasks.json可以用到自定義宏(例如:解決方案文件夾路徑),等用於VS2019里面的宏。
task.json 文件內容
1 {
2 // See https://go.microsoft.com/fwlink/?LinkId=733558
3 // for the documentation about the tasks.json format
4 "version": "2.0.0",
5 "tasks": [
6 {
7 "label": "copy-template-wwwroot",
8 "command": "${command:extension.commandvariable.workspace.workspaceFolderPosix}/build/template-copy",
9 "args": [
10 "${command:extension.commandvariable.workspace.workspaceFolderPosix}"
11 ],
12 "type": "shell",
13 "group": "build",
14 "presentation": {
15 "reveal": "silent"
16 },
17 "problemMatcher": "$msCompile"
18 },
19 {
20 "label": "template-1000",
21 "command": "${command:extension.commandvariable.workspace.workspaceFolderPosix}/build/template-build",
22 "args": [
23 "${command:extension.commandvariable.workspace.workspaceFolderPosix}",
24 "1000"
25 ],
26 "type": "shell",
27 "group": "build",
28 "presentation": {
29 "reveal": "silent"
30 },
31 "problemMatcher": "$msCompile"
32 },
33 {
34 "label": "template-1001",
35 "command": "${command:extension.commandvariable.workspace.workspaceFolderPosix}/build/template-build",
36 "args": [
37 "${command:extension.commandvariable.workspace.workspaceFolderPosix}",
38 "1001"
39 ],
40 "type": "shell",
41 "group": "build",
42 "presentation": {
43 "reveal": "silent"
44 },
45 "problemMatcher": "$msCompile"
46 },
47 {
48 "label": "template-1002",
49 "command": "${command:extension.commandvariable.workspace.workspaceFolderPosix}/build/template-build",
50 "args": [
51 "${command:extension.commandvariable.workspace.workspaceFolderPosix}",
52 "1002"
53 ],
54 "type": "shell",
55 "group": "build",
56 "presentation": {
57 "reveal": "silent"
58 },
59 "problemMatcher": "$msCompile"
60 },
61 {
62 "label": "template-1003",
63 "command": "${command:extension.commandvariable.workspace.workspaceFolderPosix}/build/template-build",
64 "args": [
65 "${command:extension.commandvariable.workspace.workspaceFolderPosix}",
66 "1003"
67 ],
68 "type": "shell",
69 "group": "build",
70 "presentation": {
71 "reveal": "silent"
72 },
73 "problemMatcher": "$msCompile"
74 },
75
76 {
77 "label": "build-template",
78 "command": "${command:extension.commandvariable.workspace.workspaceFolderPosix}/build/template-build",
79 "args": [
80 "${command:extension.commandvariable.workspace.workspaceFolderPosix}"
81 ],
82 "type": "shell",
83 "group": "build",
84 "presentation": {
85 "reveal": "silent"
86 },
87 "problemMatcher": "$msCompile"
88 },
89 {
90 "label": "build-www",
91 "command": "dotnet",
92 "type": "shell",
93 "args": [
94 "build",
95 "-p:SkipPostBuild=True",
96 "${command:extension.commandvariable.workspace.workspaceFolderPosix}/meshop/MeShop.View.WWW/MeShop.View.WWW.csproj"
97 ],
98 "group": "build",
99 "presentation": {
100 "reveal": "silent"
101 },
102 "dependsOn":["build-template"],
103 "problemMatcher": "$msCompile"
104 }
105 ]
106 }
launch.json 文件內容
1 {
2 // 使用 IntelliSense 了解相關屬性。
3 // 懸停以查看現有屬性的描述。
4 // 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387
5 "version": "0.2.0",
6 "configurations": [
7 {
8 "name": "meshop-www",
9 "type": "coreclr",
10 "request": "launch",
11 "preLaunchTask": "build-www",
12 "program": "${workspaceFolder}/meshop/MeShop.View.WWW/bin/Debug/MeShop.View.WWW.dll",
13 "args": [
14
15 ],
16 "cwd": "${workspaceFolder}/meshop/MeShop.View.WWW",
17 "stopAtEntry": false,
18 "serverReadyAction": {
19 "action": "openExternally",
20 "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
21 },
22 "requireExactSource": false,
23 "env": {
24 "HOST_ADMIN": "deverr",
25 "ASPNETCORE_ENVIRONMENT": "Development",
26 "MESHOP_CDN": "cdn.meshop.net"
27 },
28 "sourceFileMap": {
29 "/Views": "${workspaceFolder}/Views"
30 }
31 }
32 ]
33 }


