【问题标题】:Can a command be send to VSCode, directly from the integrated terminal (integrated terminal -> VSCode API)?可以直接从集成终端(集成终端-> VSCode API)向 VSCode 发送命令吗?
【发布时间】:2021-07-22 21:31:51
【问题描述】:

您好,我想知道是否可以从集成终端调用 VSCode 命令。所以基本上终端知道VSCode并且他们可以通信(至少从终端=> VSCode)

我的用例:我想要HL,移动到终端左侧/右侧的编辑器选项卡(我在编辑器选项卡中使用终端)。此外,当我在 zsh 中处于 vim 正常模式时,我希望这种情况发生。

所以我想,当我处于正常模式并按 H 时,终端会向 VSCode 发送 editor.tabNext(或任何命令)。

【问题讨论】:

    标签: visual-studio-code


    【解决方案1】:

    我想我至少找到了解决方法。有一个名为Remote Control (https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-remote-control&ssr=false#review-details) 的扩展,我可以使用它向 VSCode 发送任意命令,所以这似乎可行。可能在本地这是不可能的,但也许有人知道一些事情。

    EDIT1:

    这是我现在的设置:

    if [ ! -z $VSCODE ]; then 
      _sendcmd() { echo "{ \"command\": \"workbench.action.$1\" }" | websocat ws://localhost:4242 }
      # define commands and register them in zsh
      editor_left() { _sendcmd previousEditor }; zle -N editor_left;
      editor_right() { _sendcmd nextEditor }; zle -N editor_right;
      bindkey -a H editor_left
      bindkey -a L editor_right
    fi
    

    $VSCODE 在 VSCode 中通过 terminal.integrated.env = { "VSCODE": "1" } 定义。愿这让你和我一样快乐。

    【讨论】:

      猜你喜欢
      • 2021-11-01
      • 1970-01-01
      • 2019-06-12
      • 1970-01-01
      • 2018-03-09
      • 2021-09-12
      • 2023-03-11
      • 1970-01-01
      • 2016-11-27
      相关资源
      最近更新 更多