简体   繁体   English

嵌套终端的颜色方案,tmux,ssh,vim设置

[英]Color scheme of a nested terminal, tmux, ssh, vim setup

On my local computer, iterm terminal contains tmux. 在我的本地计算机上,iterm终端包含tmux。 Inside tmux, there is ssh remote connection. 在tmux里面,有ssh远程连接。 In this remote connection, I run tmux in server side. 在这个远程连接中,我在服务器端运行tmux。 Inside that tmux, I run vim. 在那个tmux中,我运行vim。

So, the container relationship is the following: First iterm, then tmux, then ssh remote connection, then tmux, then vim. 所以,容器关系如下:首先是iterm,然后是tmux,然后是ssh远程连接,然后是tmux,然后是vim。

Now, how are the colors of vim determined? 现在,vim的颜色是如何确定的? Which color scheme of which application is effective? 哪种应用有效的配色方案?

The colors you see are, in fine, limited by the "physical" capabilities of your terminal emulator but their number is generally altered by the TERM environment variable that is used by programs to determine how fancy they can be in their coloring. 您看到的颜色很好地受到终端仿真器的“物理”功能的限制,但它们的数量通常由TERM环境变量改变,程序使用它来确定它们在着色中的可能性。

In simplistic terms… 用简单的术语......

  • when Vim checks your TERM and sees a value containing 256 , it assumes your terminal emulator is capable of displaying 256 colors and acts accordingly. 当Vim检查你的TERM并看到一个包含256的值时,它假定你的终端仿真器能够显示256种颜色并相应地动作。

  • when your TERM is xterm or screen (among others), Vim assumes your terminal emulator is only capable of displaying 8 colors and acts accordingly. 当您的TERMxtermscreen (以及其他)时,Vim假定您的终端仿真器只能显示8种颜色并相应地采取行动。

Assuming your current TERM in your local terminal emulator is xterm-256color and none of the intermediary *rc sets a specific TERM : 假设您在本地终端仿真器中的当前TERMxterm-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, as a terminal multiplexer, acts as if it was a terminal emulator and changes your TERM to tmux's default value, screen , and that new value is what is passed down along the chain. Tmux作为终端多路复用器,就好像它是一个终端仿真器,并将你的TERM更改为tmux的默认值, screen ,并且新值是沿链传递的值。

If you want tmux and fancy colors everywhere, you need to configure each tmux to use a 256 colors-ready TERM . 如果你想在任何地方使用tmux 奇特的颜色,你需要配置每个tmux使用256色准备好的TERM Put this line in ~/.tmux.conf on every machine you log in, including yours: 在您登录的每台计算机上将此行放在~/.tmux.conf中,包括您的:

set-option -g default-terminal "screen-256color"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM