lose vim colorscheme in tmux mode

后端 未结 20 1739
说谎
说谎 2020-12-12 09:13

I\'m running iterm2 and when I\'m in tmux mode the colorscheme I have set in vim does not show up. Only the color scheme I\'ve set in iterm. If I run vim from shell the colo

相关标签:
20条回答
  • 2020-12-12 09:30

    I just discovered why I was having a lot of confusion. I, like others here, was having a difficult time getting the default-terminal setting to take effect. I remembered that I had a tmux session in the background. I re-attached my session, closed out my processes, and closed ALL tmux processes. The next time I restarted tmux the default-terminal setting in .tmux.conf began to take effect. I don't know if others are doing this as well but I recommend closing all tmux processes before modifying the .tmux.conf file.

    I got my setup to work on my local machine (OSX 10.9.5 with iTerm2) without any modification to .bashrc or .bash_profile. All I did was add the line set -g default-terminal "xterm-256color" to ~/.tmux.conf and restarted all tmux processes.

    I got my remote setup (ssh to Ubuntu 14.04) to work exactly the same way without any modifications to .bashrc. I simply added set -g default-terminal "xterm-256color" to ~/.tmux.conf on my remote machine and restarted all remote tmux processes.

    You can test what Vim is seeing by doing echo $TERM from within a tmux session. It kept saying screen as the value until I restarted all tmux processes, at which point it reflected xterm-256color as expected.

    Hope that helps.

    0 讨论(0)
  • 2020-12-12 09:31

    In case anyone needs 24-bit color support:

    Tmux supports 24-bit color as of version 2.2. If your terminal supports 24-bit color, add your terminal to the terminal-overrides setting. For example,

    set -ga terminal-overrides ",xterm-256color:Tc"
    

    My environment checklist:

    • macOS Sierra 10.12.3
    • iTerm2 3.0.14 (Report Terminal Type is xterm-256color)
    • neovim 0.1.7 (Enable 24-bit color by adding: xterm-256color to .vimrc)
    • tmux 2.3 (Add set -ga terminal-overrides ",xterm-256color:Tc" to .tmux.conf)

    Nothing else I need to add in .bashrc or .zshrc.

    Hope this could help.

    0 讨论(0)
  • 2020-12-12 09:33

    So this a bit on the stale side, but it's might be worth mentioning that using screen will often break the Home and End keys. Using

    export TERM="xterm-256color"
    

    in should keep the functionality of these and allow the color scheme (or powerline) to work fine.

    0 讨论(0)
  • 2020-12-12 09:33

    Since this is the first result on Google and since none of the above helped..wanted to post this so that someone might find it helpful

    in .vimrc:

    set background=dark
    set t_Co=256
    

    HTH

    0 讨论(0)
  • 2020-12-12 09:36

    I tried all the solutions above and what finally worked for me is putting the following lines in .tmux.conf:

    set -g default-terminal "xterm-256color"
    
    0 讨论(0)
  • 2020-12-12 09:38

    In order to set up correct color and to get rid of rendering issue in both Ubuntu and Mac:

    check this

    0 讨论(0)
提交回复
热议问题