【问题标题】:Tmux will not stop auto-renaming windowsTmux 不会停止自动重命名窗口
【发布时间】:2016-07-23 16:07:58
【问题描述】:

我在使用 Tmux 时遇到的一个问题 - 在 .tmux.conf 文件中,我告诉他在我设置它们的名称后不要重命名窗口,但这似乎不是“尊重我的权威”:)。

我的系统:

  • OSX El Capitan
  • Tmux 2.1(通过 Brew 安装)
  • Zshell

这是我的 ~/.tmux.conf 内容(我很抱歉它很长):

# set correct term
set -g default-terminal screen-256color

# set prefix key to ctrl+a
#unbind C-b
set -g prefix C-a 

# reload config without killing server
bind R source-file /users/edchigliak/.tmux.conf 

# enable wm window titles
set -g set-titles on

# disable auto renaming
set -g automatic-rename off

# border colour
set -g pane-border-fg blue
set -g pane-border-bg default
set -g pane-active-border-fg blue
set -g pane-active-border-bg default

# wm window title string (uses statusbar variables)
set -g set-titles-string "tmux:#I [ #W ]"

# initialize sessions
bind S source-file ~/.tmux.conf 
bind I source-file ~/.tmux.conf

# environment
set -g update-environment "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"

# statusbar --------------------------------------------------------------
set -g window-status-format "#I:#W"
set -g window-status-current-format "#I:#W"

set -g status-keys vi
bind-key -t vi-edit Up history-up
bind-key -t vi-edit Down history-down

set -g status-interval 1
set -g status-justify centre # center align window list

# default statusbar colors
# wm window title string (uses statusbar variables)
set -g set-titles-string "tmux:#I [ #W ]"

# initialize sessions
bind S source-file ~/.tmux.conf 
bind I source-file ~/.tmux.conf

# environment
set -g update-environment "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"

# statusbar --------------------------------------------------------------
set -g window-status-format "#I:#W"
set -g window-status-current-format "#I:#W"

set -g status-keys vi
bind-key -t vi-edit Up history-up
bind-key -t vi-edit Down history-down

set -g status-interval 1
set -g status-justify centre # center align window list

# default statusbar colors
set -g status-fg white
set -g status-bg default

# default window title colors
set-window-option -g window-status-fg black
set-window-option -g window-status-bg default
set-window-option -g window-status-attr dim

# active window title colors
set-window-option -g window-status-current-fg white
set-window-option -g window-status-current-bg default
set-window-option -g window-status-current-attr dim

# command/message line colors
set -g message-fg white
set -g message-bg black
set -g message-attr bright

# Statusbar starting in X or not
# if '[ -n "$DISPLAY" ]' 'source-file ~/.tmux/inx'
# if '[ -z "$DISPLAY" ]' 'source-file ~/.tmux/xless'

如果我尝试:

~> 回显 $TERM

我猜对了:

屏幕 256 色

这让我相信它正在采购正确的 .conf 文件。此外,控制键绑定确实从Ctrl+b 更改为Ctrl+a。但是,我通过Ctrl + a,simply 更改的窗口名称不会保留。

有什么想法吗?谢谢!

【问题讨论】:

  • 可能是zsh,它正在改变你的窗口标题,尤其是当你启动一个程序或发出shell提示时标题才改变。你有没有机会链接你的shell配置?否则,查找具有以\e]2;\033]2; 开头并以\a\e\` or \033\` 结尾的字符串的printecho 语句。
  • 你是对的! ZSH 把事情搞砸了。我不得不在我的.zshrc 中取消注释这一行export DISABLE_AUTO_TITLE="true"。请回答我的问题,我很乐意接受。

标签: macos tmux oh-my-zsh


【解决方案1】:

一个可能的原因是,zsh 被配置为在启动程序或发出提示时更新窗口标题。这是通过使用终端转义序列\ek<TEXT>\e\\ 完成的,其中<TEXT> 是窗口标题。

为了防止这种情况,您有两种选择:

  • tmux 配置中不允许窗口重命名。

    只需添加

    set allow-rename off
    

    到您的~/.tmux.conf。这可以防止任何程序使用上述终端转义序列更改窗口标题。

  • 追踪您的 zsh 配置中的设置并将其禁用。

    如果你使用的是oh-my-zsh,设置应该足够了

    DISABLE_AUTO_TITLE="true"
    

    在您的~/.zshrc 中(或者直接取消注释,如果您使用的是来自oh-my-zsh 的默认.zshrc 模板)。

    如果您使用自己的配置或其他配置框架,您应该可以通过搜索\ek 来追踪它(如果您的搜索工具需要,请不要忘记引用反斜杠)。

【讨论】:

  • 啊,谢谢谢谢谢谢!这简直要了我的命 :) :) :)
  • 请记住用tmux source-file ~/.tmux.conf重新加载配置文件
  • 我想强调此设置是每个窗口。如果你从一个脚本创建多个窗口,你必须在每个窗口创建命令之后加上set allow-rename off,因为那将是那个时候的活动窗口。
【解决方案2】:

对于运行 bash 并登陆此结果的人来说,设置标题的东西是 PROMPT_COMMAND 环境变量,一些共享系统烦人地设置了它。您可以使用 unset PROMPT_COMMAND 来做到这一点(例如在您的 .bashrc 中)

【讨论】:

【解决方案3】:

为此,我必须将此行添加到 ~/.tmux.conf

set-window-option -g allow-rename off

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-03
    • 1970-01-01
    • 2012-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-06
    相关资源
    最近更新 更多