Ale*_*lex 7 command-line-interface visual-studio-code
我习惯于通过按两次Ctrl+来终止 CLI 中的进程,C但这在 vscode 的集成终端中不起作用。它提示确认。有没有办法以同样的方式使用它?或者甚至更好,使用 1 个按键。
Mar*_*ark 10
通过转到文件添加"workbench.action.terminal.sendSequence"到terminal.integrated.commandsToSkipShellsettings.json 中的列表?喜好 ?设置,然后搜索字符串terminal.integrated.commandsToSkipShell,然后单击“在 settings.json 中编辑”。
如果"terminal.integrated.commandsToSkipShell"settings.json 中没有条目,只需添加它:
... ,
"terminal.integrated.commandsToSkipShell": [
"workbench.action.terminal.sendSequence"
]
Run Code Online (Sandbox Code Playgroud)
然后您还需要添加以下键绑定(文件?首选项?键盘快捷键?打开 keybindings.json):
{
"key": "ctrl+c",
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u0003Y\u000D"
},
"when": "terminalFocus && !terminalTextSelected"
}
Run Code Online (Sandbox Code Playgroud)
请注意,此解决方案需要您使用Ctrl-C 两次,并且仅适用于 Visual Studio Code 终端。
这也将改变你在依赖于两个终端中运行任何工具的行为ctrl-c说明:因为你现在发送大写字母Y和换行符作为第二个指令来代替,确保无论你正在运行有退出的另一种手段可用的。
您可以通过添加以下设置来使用多命令扩展:
"multiCommand.commands": [
{
"command": "multiCommand.terminateTerminal",
"interval": 1000,
"sequence": [
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u0003"
}
},
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "Y\u000D"
}
},
]
}
Run Code Online (Sandbox Code Playgroud)
在interval提供了两个之间的暂停sendSequence命令,并且被两个命令都需要:
u\003 是文本结束(插入符号 = ^C)。
u\000D是一个Return。
然后在 keybindings.json 中添加一个键绑定:
{
"key": "ctrl+shift+c",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.terminateTerminal" },
},
Run Code Online (Sandbox Code Playgroud)
某些组合键将无法工作(如标准序列Ctrl-C两次),但Ctrl- - Shift,C光标焦点是否在编辑器,文件浏览器,或者它运作良好的终端。
请注意,这不会杀死或关闭终端或影响其历史记录,它只会在那里停止当前的工作。
| 归档时间: |
|
| 查看次数: |
5576 次 |
| 最近记录: |