How to actually get italics and true colour to work in iTerm + tmux + vim
There’s lots of partial/out-of-date info on this so I thought I’d post what actually worked for me.
xterm-256color-italic|xterm with 256 colors and italic,
tmux-256color|tmux with 256 colors,khome=\E[1~, kend=\E[4~,
ritm=\E[23m, rmso=\E[27m, sitm=\E[3m, smso=\E[7m, Ms@,
That third line is necessary to make home and end keys work inside tmux.
Then to install them, run:
tic -x xterm-256color-italic.terminfo
$ tic -x tmux-256color.terminfo
Go to Preferences > Profiles > Default.
Make sure Text > Italic text allowed is checked.
Set Terminal > Report Terminal Type to
This essentially sets the value of the environment variable
TERM, which you could also set in your
~/.bashrc etc, depending on how you want to store your settings.
You need at least about version 2.5 (2.3 at least prevents backgrounds from working).
Add this to your
set -g default-terminal 'tmux-256color'
set -as terminal-overrides ',xterm*:Tc:sitm=\E[3m'
This again sets
TERM inside tmux. The second line is even more important though:
Tc allows vim to enable true colours, and and
sitm allows the same with italics.
As far as I can tell, aliasing
tmux -2 isn’t necessary.
You need a relatively recent version, but 8.0 should be fine.
Add the following to your
The first two lines forces true colour on, since vim can’t detect it within tmux. The last line on its own will work outside tmux, but result in no colours inside tmux.
Again, as far as I can tell, stuff like setting
t_Co isn’t necessary.
Of course you need a theme which supports true colour and italics to really test this. I’d recommend gruvbox, and setting
Hacking all this stuff in may break some things. One that will definitely break is that
ssh forwards your
TERM (which can’t be disabled), and since we’re using custom ones they won’t exist on the remote server. I’d recommend adding the following alias to your
alias ssh='TERM=xterm-256color ssh'
This terminal should exist on most servers. If you still have issues, try just
However, if you have a server you use regularly, you can get this working on there as well. Basically follow the same steps as above on the server and it should work. Again the custom
TERM may break other things, like
ls colours, which I fix with:
eval $(TERM=xterm dircolors)
alias ls='ls --color=auto'
Italics and true colours in