在 Tmux 中更改活动或非活动窗格的背景颜色 [英] Change background color of active or inactive pane in Tmux

查看:51
本文介绍了在 Tmux 中更改活动或非活动窗格的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何选项可以控制 Tmux 中活动或非活动窗格的背景颜色?

Are there any options to control the background color of the active or inactive panes in Tmux?

推荐答案

看来 tmux-2.1 (2015 年 10 月 18 日发布)现在允许指定单个窗格的颜色.来自更改日志:

It seems that tmux-2.1 (released 18 October 2015) now allows the colours of individual panes to be specified. From the changelog:

* 'select-pane' now understands '-P' to set window/pane background colours.

例如[来自手册] 将窗格 1 的前景(文本)更改为蓝色,将背景更改为红色使用:

e.g. [from the manual] to change pane 1's foreground (text) to blue and background to red use:

select-pane -t:.1 -P 'fg=blue,bg=red'

模仿 iTerm 配色方案:

为了回答最初的问题,我在 ~/.tmux.conf 中使用以下几行来设置背景/前景色以模仿 iTerm:

To mimic iTerm colour scheme:

To answer the original question, I use the following lines in my ~/.tmux.conf for setting the background/foreground colours to mimic the behaviour in iTerm:

#set inactive/active window styles
set -g window-style 'fg=colour247,bg=colour236'
set -g window-active-style 'fg=colour250,bg=black'

# set the pane border colors 
set -g pane-border-style 'fg=colour235,bg=colour238' 
set -g pane-active-border-style 'fg=colour51,bg=colour236'

我之前没有见过 window-stylewindow-active-style 命令,但也许它们在以前的 tmux 版本中可用.

I hadn't seen the window-style and window-active-style commands before, but maybe they were available in previous tmux versions.

此外,这两行对于轻松拆分窗格非常有用:

Also, these two lines are pretty useful for splitting panes easily:

bind | split-window -h
bind - split-window -v

编辑:正如 Jamie Schembri 在评论中提到的,tmux 2.1 版(至少)现在将安装:

EDIT: as Jamie Schembri mentions in the comments, tmux version 2.1 (at least) will now be installed with:

brew install tmux

编辑(2017 年 10 月):brew 现在安装 tmux 2.6,以上仍然有效.

EDIT (Oct 2017): brew now installs tmux 2.6, and the above still works.

编辑 Vim 窗格:如果您发现非活动着色"不适用于 Vim 窗格,则可能是由于您使用的颜色方案.尝试使用 pablo 方案;即在 Vim 窗格中:

EDIT Vim panes: If you find that the "inactive colouring" does not work with a Vim pane, it might be due to the colourscheme you are using. Try with the pablo scheme; i.e. in the Vim pane:

:colo pablo

要使其与您自己的自定义 Vim 颜色方案一起使用,请确保 Normal 突出显示的设置没有指定 ctermbgguibg.例如,非活动着色"不适用于 murphy 颜色方案,因为在 murphy.vim 中有一行:

To make it work with your own custom Vim colourscheme, make sure that the setting for Normal highlighting does not have ctermbg or guibg specified. As an example, the "inactive colouring" does not work with the murphy colourscheme, because in murphy.vim there is the line:

hi Normal    ctermbg=Black   ctermfg=lightgreen   guibg=Black   guifg=lightgreen

ctermbgguibg 设置为 Black.但是,将此行更改为:

that sets ctermbg or guibg to Black. However, changing this line to:

hi Normal    ctermfg=lightgreen  guifg=lightgreen

将使非活动着色"起作用.

will make the "inactive colouring" work.

EDIT 2019 年 7 月 Augusto 提供了一个很好的建议,还可以更改行号.我在 vim 配色方案中使用的是以下内容:

EDIT July 2019 Augusto provided a good suggestion for also changing the background colour for the line numbers. What I use in my vim colourscheme is the following:

hi Normal    guifg=#e6e1de ctermfg=none gui=none
hi LineNr    guifg=#e6e1de ctermfg=none gui=none

这篇关于在 Tmux 中更改活动或非活动窗格的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆