visual-studio-code - 带有目录的VSCode打开终端似乎不起作用
问题描述
找到VSCode 命令 workbench.action.terminal.newWithCwd
{
"key": "cmd+shift+alt+h",
"command": "workbench.action.terminal.newWithCwd",
"args": {
"cwd": "${fileDirname}"
}
}
我无法让它工作。
我已经将上面的 JSON 插入到~\Code\User\keybindings.json
文件中,但我如何真正让它执行呢?
解决方案
这可以用作键绑定,使用宏扩展multi-command:
{
"key": "alt+k", // whatever you want here
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
{
"command": "workbench.action.terminal.newWithProfile",
"args": {
"profileName": "Git Bash",
"shouldForwardArgs": true,
}
}
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "cd '${fileDirname}'\u000D"
}
}
]
},
"when": "editorTextFocus"
},
我认为应该起作用的是settings.json中的这个配置文件:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash",
"path": "C:\\Program Files\\Git\\git-bash.exe"
},
"Git Bash at fileDirname": {
"source": "Git Bash",
"path": "C:/Program Files/Git/git-bash.exe",
"args": [
"cd ${fileDirname}" // variables are supported here according to the docs
]
}
},
然后是这个关联的键绑定:
{
"key": "alt+k",
"command": "workbench.action.terminal.newWithProfile",
"args": {
"profileName": "Git Bash at fileDirname",
"shouldForwardArgs": true
}
},
但这对我来说不太奏效。它几乎可以工作,但它说不存在这样的文件。我在配置文件中看到了一些关于可变分辨率的问题。
推荐阅读
- javascript - 使用javascript在aspx中回发后保持Div可见或隐藏
- windows-community-toolkit - 用于脚本的 WebView 对象 / Window.External
- r - 如何将日期转换为 FY 半年刊
- javascript - 如何在 VueJS SFC 中的数据、计算、方法中使用 JSX
- python - 如何在python中将多个json文件合并为一个文件
- google-maps - 对 Google Maps API 应用“网站限制”需要多长时间?
- json - 使用 postgresql 更新 json 字符串值
- vba - 在 Date 变量中无效使用 null
- react-native - 标题滚动时React Native无法折叠标题
- rust - 如何使用命名参数解析 &str?