如何通过单击启动多个集成终端面板?

时间:2016-10-13 03:39:51

标签: macros installation visual-studio-code init

在Visual Studio Code中,我希望能够按下按钮或运行一个命令来创建多个终端面板并在其上运行命令。

这在处理存储在经常卸载的驱动器中的代码时非常有用,每次安装时都必须启动一些终端并导航到正确的目录。

有可能吗?

1 个答案:

答案 0 :(得分:0)

在Mac上,我们可以利用AppleScript的强大功能来实现这一目标。

首先,我们需要添加一个用于创建新终端实例的击键:

{ "key": "cmd+n", "command": "workbench.action.terminal.new", "when": "terminalFocus" }

其次,我们创建AppleScript,如下所示:

tell application "Visual Studio Code" to activate tell application "System Events" # Term 1 keystroke "`" using control down keystroke "cd path/number/1" keystroke return # Term 2 keystroke "n" using command down keystroke "cd path/number/2" keystroke return # Term 3 keystroke "n" using command down keystroke "cd path/number/3" keystroke return # End keystroke "`" using control down end tell

最后,我们使用以下命令添加VSC任务:

osascript ./my_script.scpt

然后运行任务。

我希望有人会觉得这很有帮助。