TrueColor in Gnome Terminal, Tmux and Neovim

Here is where we are right now: https://gist.github.com/XVilka/8346728 . As you can see, most of the editors and terminals now support TrueColor (16 million colors).

The result

Difference between TrueColor (24bits - 16 million colors) and “256colors” (8bits - 256 colors):

Original theme (gruvbox):

TrueColor looks better and comfier for your eyes. So, there is no excuse not to use it.

Gnome Terminal

gnome-terminal has to be in version linked against libvte >= 0.36.

  1. Check
ldd /usr/lib/gnome-terminal/gnome-terminal-server | grep libvte
  1. Install
sudo add-apt-repository ppa:gnome3-team/gnome3-staging
sudo apt-get update
sudo apt-get install -y gnome-terminal
sudo add-apt-repository -r ppa:gnome3-team/gnome3-staging
  1. Restart gnome-terminal-server (I’ve just rebooted my machine, but killing the corresponding process should also do the job).

Links:

Tmux

tmux must be >= 2.2.

  1. Check
tmux -V
  1. Kill tmux (tmux kill-server) and (optionally) remove it

  2. Install

On Ubuntu:

sudo apt-get install -y libevent-dev libncurses-dev build-essential
wget https://github.com/tmux/tmux/releases/download/2.2/tmux-2.2.tar.gz && \
  tar -xzvf tmux-2.2.tar.gz && \
  cd tmux-2.2 && \
  ./configure && \
  make && \
  sudo make install
  1. Alias tmux or set $TERM env variable
alias tmux="env TERM=xterm-256color tmux"
  1. Set option, which overrides default terminal
# .tmux.conf
set-option -ga terminal-overrides ",xterm-256color:Tc"
  1. Check (inside tmux)
tmux info | grep Tc

If the command reports Tc: [missing], then support for 24-bit colors has not been enabled properly because the terminal-overrides option may have specified the outer terminal’s $TERM value incorrectly or because tmux may have been reattached to an entirely different outer terminal altogether.

Links:

Neovim

  1. Set env variable
" .nvimrc
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
  1. Pick a theme, which does not force 256 colors if !has('gui_running') or checks for neovim (discussion):

Links:

My dotfiles: https://github.com/melekes/dotfiles

Comments

comments powered by Disqus