【问题标题】:Color scheme of a nested terminal, tmux, ssh, vim setup嵌套终端、tmux、ssh、vim 设置的配色方案
【发布时间】:2014-11-07 09:41:53
【问题描述】:
在我的本地计算机上,iterm 终端包含 tmux。在 tmux 内部,有 ssh 远程连接。在这个远程连接中,我在服务器端运行 tmux。在那个 tmux 里面,我运行 vim。
所以,容器关系如下:首先是iterm,然后是tmux,然后是ssh远程连接,然后是tmux,然后是vim。
现在,vim 的颜色是如何确定的?哪个应用的哪个配色方案有效?
【问题讨论】:
标签:
vim
terminal
tmux
color-scheme
【解决方案1】:
您看到的颜色通常受终端仿真器的“物理”功能的限制,但它们的数量通常由TERM 环境变量更改,程序使用该环境变量来确定它们在他们的着色。
简单来说……
假设您当前在本地终端模拟器中的TERM 是xterm-256color,并且没有一个中介*rc 设置特定的TERM:
WHERE TERM COLORS
--------------------------------------------------------------
local xterm-256color 256
local > vim xterm-256color 256
local > remote xterm-256color 256
local > remote > vim xterm-256color 256
local > remote > remote > remote > remote > remote > remote >
> remote > remote > remote > remote xterm-256color 256
local > remote > tmux screen 8
local > remote > tmux > vim screen 8
local > tmux screen 8
local > tmux > vim screen 8
local > tmux > remote screen 8
local > tmux > remote > tmux screen 8
local > tmux > remote > tmux > vim screen 8
Tmux 作为一个终端多路复用器,它就像一个终端仿真器一样工作,并将您的 TERM 更改为 tmux 的默认值 screen,而这个新值就是沿链向下传递的值。
如果您希望 tmux 和 到处都是花哨的颜色,您需要将每个 tmux 配置为使用 256 色就绪 TERM。在您登录的每台机器(包括您的机器)上,将此行放在 ~/.tmux.conf 中:
set-option -g default-terminal "screen-256color"