无法将tmux窗口标题设置为当前程序

时间:2018-06-28 13:24:30

标签: tmux

我对tmux相当陌生,并且已经使用了一周左右。我希望将tmux窗口标题设置为我正在运行的当前程序,例如vim / htop等,而不是我连接的主机。

下面是我的配置,按照tmux手册页#W的使用,但是在我看来,它不起作用,并且我的窗口标题始终设置为fqdn[username]

set -g status on
set -g status-interval 1
set -g status-fg colour231
set -g status-bg colour234
set -g status-left-length 20



set -g status-left '#{?client_prefix,#[fg=colour254]#[bg=colour31]#[bold],#[fg=colour16]#[bg=colour254]#[bold]} #S #{?client_prefix,#[fg=colour31]#[bg=colour234]#[nobold],#[fg=colour254]#[bg=colour234]#[nobold]}'


set -g window-status-format "#[fg=colour244,bg=colour234]#I #[fg=colour240] #[default]#W "
set -g window-status-current-format "#[fg=colour234,bg=colour31]#[fg=colour117,bg=colour31] #I  #[fg=colour231,nobold]#W #[fg=colour31,bg=colour234,nobold]"
set -g window-status-last-style fg=colour31
set-window-option -g window-status-fg colour249

set -g status-right-length 150
set -g status-right  "#[fg=colour225,bg=colour234]#[fg=colour234,bg=colour225] #(date +%a' '%b' '%d) %H:%M#[fg=colour234]#[bg=colour234]#{?pane_synchronized,#[bg=colour236]#[fg=colour160]#[fg=colour255]#[bg=colour160] PANES-ARE-SYNCED !! #[fg=colour234]#[bg=colour=234],#[fg=colour22]#[fg=colour255]#[bg=colour22] PANES-NOT-SYNCED #[fg=colour234]#[bg=colour234]}#[fg=colour255,bg=colour234]#[fg=colour234,bg=colour255,bold]#h"

所以任何人都可以让我知道我该怎么做。

1 个答案:

答案 0 :(得分:0)

我发现在某些机器上我会得到一个username@hostname:~,而在其他机器上我会得到可执行文件的名称。在两台计算机上,tmux show -gw显示:

automatic-rename on
automatic-rename-format "#{?pane_in_mode,[tmux],#{pane_current_command}}#{?pane_dead,[dead],}"

所以我想知道发生了什么...事实证明,选项allow-renameon,在这里我可以看到username@hostname:~,在off,我可以看到当前的可执行文件名称。

allow-rename使您的shell(在我的情况下为bash)可以使用转义序列和某些配置(例如,如果您的TERM环境变量以{{1 }})标题将在每次显示提示时进行更新(这更多是与shell相关的问题,因此,如果您有兴趣,请在screenPS1中查找信息)。要查看效果,请尝试以下操作:

/etc/bash/bashrc

echo -en '\033kTMUXISCOOL\033]' ; sleep 5 中运行该命令时,您应该看到当前窗格标题更改为tmux 5秒钟,然后又更改为TMUXISCOOL。通过将以下行放入username@hostname:~

~/.tmux.conf

窗格标题应显示当前可执行文件...或set -g allow-rename off 中的任何内容。

相关问题