True color support with (iTerm2 + tmux + Vim)
The terminal can be an effective workhorse for achieving a job. It is fast and agile and allows you to do get things done that would have taken you much more time than when you are limited to using the graphical user interface alone. The GUI, however, treated us with elegant visuals and a clear design that made working with it a comfortable experience that is easy on the eye. When working a lot in the terminal, one might want to borrow a piece of this visual experience in the form of an attractive true color terminal.
There is, however, some configuring to do to get a true color scheme working on a terminal emulator like iTerm, especially when combined with a terminal multiplexer like tmux.
iTerm2 true color configuration
Open iTerm2 preferences and navigate to Profiles. There, select the appropriate profile or create one.
One might want to open a tmux session automatically, to do so, select in the General tab under Command ‘Login shell’ and enter the ‘Send text at start_‘: ‘tmux _new’.
Under the tab Colors, a color preset can be chosen, like Solarized Dark.
Then, under the tab Terminal, make sure that the
Report Terminal Type is set to
tmux true color configuration
To help in configuring tmux and setting some appropriate defaults, the tmux plugin manager (tpm) can be used.
If not installed already, clone the manager to the tmux config directory:
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
Then, append to the
.tmux.conf configuration file.
# List of plugins set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-sensible' # Solarized theme set -g @plugin 'seebi/tmux-colors-solarized' set -g @colors-solarized 'dark' # Terminal type configuration set -g default-terminal "screen-256color" set -ga terminal-overrides ",xterm-256color:Tc" # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run '~/.tmux/plugins/tpm/tpm'
Note that in this case, a plugin for the Solarized theme has been included too. Furthermore, the terminal type configuration makes sure that the appropriate conventions for true color terminals are used. Note that the default terminal type is now ‘screen‘ instead of ‘xterm‘ and the original True Color support terminal type is passed through terminal-overrides.
Load the configuration: type [ctrl]+[b], then
or, restart tmux.
Vim true color configuration
Finally, Vim is to be configured. As with tmux, a plugin manager is preferred. For Vim a whole spectrum of managers is available which allow practically any package to be installed. In this case, Vundle is used.
If not installed already, install Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
Then, configure Vim’s ~/.vimrc appropriately. First, the Vundle required part:
set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim'
Then, append to the list of plugins one to enable sensible defaults
And, optionally, the solarized color scheme.
Now, enable terminalguicolors and add Vim-specific sequences for RGB colors, set the colorscheme:
" set Vim-specific sequences for RGB colors set termguicolors let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" set background=dark colorscheme solarized8
And finally, append to the end of the
" All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required
Save the file. To load it and install the plugins, execute in Vim:
:source % :PluginInstall