V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
yp0808
V2EX  ›  macOS

请教怎么修改 macos 终端窗口标题?

  •  
  •   yp0808 · Oct 26, 2018 · 2978 views
    This topic created in 2746 days ago, the information mentioned may be changed or developed.
    不是命令行前的提示符,是窗口标题
    7 replies    2018-10-27 00:15:35 +08:00
    lululau
        1
    lululau  
       Oct 26, 2018
    如果你说的 “ macos 终端” 指的是 终端.appTerminal.app ) 的话:
    lululau
        2
    lululau  
       Oct 26, 2018
    printf '\e]2;My Title\a';
    lululau
        3
    lululau  
       Oct 26, 2018
    前提是确保没有在 shell 的某些 hook 里重置了标题,比如 bash: $PROMPT_COMMAND, zsh: $precmd_functions, $preexec_functions, precmd 等等
    yp0808
        4
    yp0808  
    OP
       Oct 26, 2018
    @lululauterminal.app 安装了 oh my zsh, 窗口标题是动态的。不太懂怎么重置,怎么确定有没有你所说的情况呢?
    lululau
        5
    lululau  
       Oct 26, 2018   ❤️ 1
    在 .zshrc 中添加:ZSH_THEME_TERM_TITLE_IDLE="xxxx"

    xxxx 就是你要显示的文字,其中可以有格式符,格式符参考 man zshmisc,搜 PROMPT ESCAPES
    yp0808
        6
    yp0808  
    OP
       Oct 26, 2018
    @lululau 谢谢
    GGemini
        7
    GGemini  
       Oct 27, 2018
    终端.app 直接提供这个功能 终端.app -> 偏好设置 -> 描述文件 -> 窗口 这里就直接提供标题修改了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   800 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 21:55 · PVG 05:55 · LAX 14:55 · JFK 17:55
    ♥ Do have faith in what you're doing.