Tmux不会停止自动重命名窗口

Ale*_*uck 13 macos tmux oh-my-zsh

我在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'
Run Code Online (Sandbox Code Playgroud)

如果我尝试:

〜> echo $ TERM

我明白了:

屏幕256color

这让我相信它正在寻找合适的.conf档案.此外,控制键绑定DO从更改Ctrl+bCtrl+a.但是,我改变的窗口名称Ctrl + a然后,根本不会保持不变.

有什么想法发生了什么?谢谢!

Ada*_*hon 31

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

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

  • 禁止在tmux配置中重命名窗口.

    只需添加

    set allow-rename off
    
    Run Code Online (Sandbox Code Playgroud)

    到你的~/.tmux.conf.这可以防止任何程序通过使用上述终端转义序列来改变窗口标题.

  • 跟踪zsh配置中的设置并禁用它.

    如果您使用的是oh-my-zsh,那么设置就足够了

    DISABLE_AUTO_TITLE="true"
    
    Run Code Online (Sandbox Code Playgroud)

    在你的~/.zshrc(或者只是取消注释它,如果你使用的.zshrcoh-my-zsh的默认模板).

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

  • 请记住使用 `tmux source-file ~/.tmux.conf` 重新加载配置文件 (4认同)

Dav*_*ide 7

对于运行 bash 并登陆此结果的人来说,设置标题的是PROMPT_COMMAND环境变量,某些共享系统烦人地设置了该变量。你可以用unset PROMPT_COMMAND(例如在你的.bashrc


Dre*_*eur 5

为了使它对我有用,我必须将此行添加到 ~/.tmux.conf

set-window-option -g allow-rename off
Run Code Online (Sandbox Code Playgroud)