[SOP1.2]设置VScode全局的tasks.json任务
2026/2/11小于 1 分钟
[SOP1.2]设置VScode全局的tasks.json任务
【必备】全局tasks.json
- 任务
vscode的全局tasks.json是会作用到全局的!
你本地的任何代码库+远程连接的也可以使用这些任务!!!
touch ~/.config/Code/User/tasks.json全局通用任务
{
// "version": "2.0.0",
"tasks": [
{
"label": "自定义=====echo 当前文件全路径",
"type": "shell",
"command": "echo ${fileDirname}/${fileBasename} ",
"problemMatcher": []
},
{
"label": "自定义=====git add 当前文件",
"type": "shell",
"command": "cd ${fileDirname} && git add ${fileBasename} ",
"problemMatcher": []
},
{
"label": "自定义=====在当前目录下git commit --amend",
"type": "shell",
"command": "cd ${fileDirname} && git commit --amend ",
"problemMatcher": []
},
{
"label": "自定义=====git push推送到远程cr分支",
"type": "shell",
"command": "cd ${fileDirname} && git push origin HEAD:refs/for/$(git rev-parse --abbrev-ref HEAD)",
"problemMatcher": []
},
{
"label": "自定义=====go run 当前文件夹下的*.go",
"type": "shell",
"command": "cd ${fileDirname} && go run *.go ",
"problemMatcher": []
},
{
"label": "自定义=====运行workspace的 web项目",
"type": "shell",
"command": "cd ${workspaceFolder} && go run main.go",
"problemMatcher": []
},
{
"label": "自定义=====看tail -f service.log日志",
"type": "shell",
"command": "cd ${workspaceFolder}/log/service/ && tail -f service.log",
"problemMatcher": []
},
{
"label": "自定义====看log日志",
"type": "shell",
"command": "bash",
"args": [
"-i",
"-c",
"cd ${workspaceFolder}/log/; exec bash -i"
],
"presentation": {
"reveal": "always",
"focus": true,
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "自定义====打开主目录",
"type": "shell",
"command": "bash",
"args": [
"-i",
"-c",
"cd ${workspaceFolder}; exec bash -i"
],
"presentation": {
"reveal": "always",
"focus": true,
"panel": "dedicated"
},
"problemMatcher": []
}
]
}