如何在 tmux 2.9a 中设置窗口标题颜色?

Mar*_*ols 2 statusbar tmux

在升级到 tmux 2.9a 版之后,我不得不更新我的配置文件,因为一些设置的名称发生了变化。状态栏窗口标题部分的颜色不再有效。这是我的配置文件的那一部分:

# set color for status bar
set-option -g status-style bg=colour235
set-option -g status-style fg=yellow
set-option -g status-style dim

# set window title list colors
set-window-option -g window-status-style fg=brightblue
set-window-option -g window-status-style bg=colour236
set-window-option -g window-status-style dim

# active window title colors
set-window-option -g window-status-current-style fg=brightred
set-window-option -g window-status-current-style bg=colour236
set-window-option -g window-status-current-style bright
Run Code Online (Sandbox Code Playgroud)

无论我选择什么颜色或亮度,状态栏的标题区域都显示白色文本。我的整个 tmux 配置文件在这里:https : //github.com/zanshin/dotfiles/blob/master/tmux/tmux.conf

cas*_*ams 11

打印默认设置值

\n
tmux -Lfoo -f/dev/null start\\; show -gw\n
Run Code Online (Sandbox Code Playgroud)\n

打印当前设置值

\n
tmux -Lfoo -f/dev/null start\\; show -g\n
Run Code Online (Sandbox Code Playgroud)\n

默认窗口选项 2.9.a

\n
window-active-style default\nwindow-size smallest\nwindow-status-activity-style reverse\nwindow-status-bell-style reverse\nwindow-status-current-format "#I:#W#{?window_flags,#{window_flags}, }"\nwindow-status-current-style default\nwindow-status-format "#I:#W#{?window_flags,#{window_flags}, }"\nwindow-status-last-style default\nwindow-status-separator " "\nwindow-status-style default\nwindow-style default\n
Run Code Online (Sandbox Code Playgroud)\n

修改建议

\n

这些颜色只是为了看到差异

\n

~/.tmux.conf

\n
# ---------------- #\n# Define Colors    #\n# ---------------- #\nGRAY="#808080"\nBLUE="#569CD6"\nDARK_BLUE="#223E55"\nRED="#EE4646"\nYELLOW="#CCCC99"\nBACKGROUND="#000000"\nFOREGROUND="#CCCCCC"\n\n# ----------------- #\n# Define Status Bar #\n# ----------------- #\nset -g status-interval 1\nset -g status-style bg=$BACKGROUND,fg=$BLUE\n\n# ------------ #\n# Define Panes #\n# ------------ #\nset -g pane-border-style fg=$DARK_BLUE\nset -g pane-active-border-style fg=$BLUE\n\n# ---------------- #\n# Define Left Side #\n# ---------------- #\nset -g status-left " "\n\n# -------------- #\n# Define Windows #\n# -------------- #\nset -g window-status-current-format "#[fg=$BLUE] \xe2\x9e\xa4 "\nset -g window-status-format " \xe2\x9e\xa4 "\nset -g window-status-activity-style fg=$RED\nset -g window-status-bell-style fg=$YELLOW\nset -g window-status-separator " "\nset -g window-style default\nset -g window-status-style bg=$BACKGROUND,fg=$GRAY\n\n# ----------------- #\n# Define Right Side #\n# ----------------- #\nset -g status-right-length 150\nset -g status-right "#T %Y-%m-%d %H:%M:%S "\n
Run Code Online (Sandbox Code Playgroud)\n


pfm*_*ggi 9

语法略有变化(我喜欢新的)。您现在可以将多个属性放在同一行上,用逗号分隔。

使用新语法,您在问题中的配置变为:

# set color for status bar
set-option -g status-style bg=colour235,fg=yellow,dim

# set window title list colors
set-window-option -g window-status-style fg=brightblue,bg=colour236,dim

# active window title colors
set-window-option -g window-status-current-style fg=brightred,bg=colour236,bright
Run Code Online (Sandbox Code Playgroud)

有关其他信息,您可以参考tmux 的常见问题解答


Nic*_*ott 1

如果多次设置某个选项,则最后一次使用的值将被使用。

您需要将每个选项设置一次,或者在每个选项的第二个和后续设置命令上使用 -a。