【问题标题】:Change Integrated Terminal title in vscode在 vscode 中更改集成终端标题
【发布时间】:2017-08-11 10:02:13
【问题描述】:

我们可以使用View菜单中的Integrated Terminal功能在vscode中打开命令提示符。

我们甚至可以打开多个终端,如下图:

有什么办法可以更改终端的标题吗?

  • 1: cmd.exe 将是构建终端
  • 2: cmd.exe 将是观看终端

我浏览了integrated terminal 文档,但没有找到方法。

【问题讨论】:

  • 我对同样的事情感兴趣,我希望能够更改标题,以便知道我要通过 ssh 访问的机器的主机名
  • 遗憾的是,微软关闭并锁定了github.com/Microsoft/vscode/issues/63264 的功能请求,现在我们需要一个用于自动重命名终端窗口的扩展,因为手动重命名在实际使用中几乎无用。

标签: visual-studio-code vscode-extensions vscode-settings


【解决方案1】:

在windows中按Ctrl + Shift + P,然后输入:终端:重命名,您可以在此处更改终端名称/标题

【讨论】:

  • 感谢您的回答
  • 对于 Mac,是 cmd + shift + p
【解决方案2】:

有时,插件会删除默认的键盘快捷键绑定。

在键盘快捷键中查找“terminal.rename”,然后将键盘快捷键编辑为您喜欢的快捷键。

要应用您的快捷方式,请确保您的光标在键入之前位于窗口的编辑部分。而不是终端部分。

【讨论】:

    【解决方案3】:

    在 v1.41 中有一个新命令可以这样使用:

    {
      "key": "ctrl+t",
      "command": "workbench.action.terminal.renameWithArg",
      "args": {
          "name": "remote"
      }
    }
    

    如果您有一些经常使用的名称,例如您经常使用的“remote”或“build”。

    【讨论】:

      【解决方案4】:

      在 v1.61 中,可以使用变量设置终端名称。见terminal custom titles in release notes

      终端名称通常是它们所在进程的名称 有关联。因此,很难区分 他们。

      我们现在支持同时配置标题和描述以帮助 这使用terminal.integrated.tabs.title 中描述的变量和 terminal.integrated.tabs.description 设置。

      当前默认值为:

      {
        "terminal.integrated.tabs.title": "${process}",
        "terminal.integrated.tabs.description": "${task}${separator}${local}${separator}${cwdFolder}"
      }
      

      可用的变量有:

      ${cwd} - The terminal's current working directory  
      ${cwdFolder} - The terminal's current working directory.  
      ${workspaceFolder} - The workspace in which the terminal was launched.  
      ${local} - Indicates a local terminal in a remote workspace.  
      ${process} - The name of the terminal process.  
      ${separator} - A conditional separator (" - ") that only shows when surrounded by variables with values or static text.  
      ${sequence} - The name provided to xterm.js by the process.  
      ${task} - Indicates this terminal is associated with a task.  
      

      看起来${task} 变量就是您要查找的变量。

      【讨论】:

        【解决方案5】:

        对于 VSCode 1.63(2021 年 11 月),输入“<blank>”(即空字符串)作为名称将恢复该终端的默认名称。

        issue 134020

        例如:

        如果我的设置是 ${cwd}${separator}${process} 并且我将终端命名为“foo”。
        如何将“foo”重置为${cwd}${separator}${process}的值?
        我的建议是,如果您尝试提交一个空白名称,该名称会自动重置为您的设置值。

        【讨论】:

          猜你喜欢
          • 2020-12-08
          • 2021-11-01
          • 2019-06-12
          • 2019-08-22
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-05-26
          • 2017-11-10
          相关资源
          最近更新 更多