Skip to content

Instantly share code, notes, and snippets.

@gyribeiro
Last active March 5, 2024 12:05
Show Gist options
  • Star 65 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save gyribeiro/4192af1aced7a1b555df06bd3781a722 to your computer and use it in GitHub Desktop.
Save gyribeiro/4192af1aced7a1b555df06bd3781a722 to your computer and use it in GitHub Desktop.
enable italic font on tmux

based on https://www.reddit.com/r/vim/comments/24g8r8/italics_in_terminal_vim_and_tmux/

  • Check if italic font is supported:
$ echo -e "\e[3mitalic\e[23m"
  • Also check:
$ infocmp $TERM | grep sitm
        sgr0=\E(B\E[m, sitm=\E[3m, smacs=\E(0, smam=\E[?7h,
$ infocmp $TERM | grep ritm
        ri=\EM, rin=\E[%p1%dT, ritm=\E[23m, rmacs=\E(B,

If nothing is returned, then here is the step to enable it:

  1. Create a the file screen-256color.terminfo with the following content:
# A screen-256color based TERMINFO that adds the escape sequences for italic.
#
# Install:
#
#   tic screen-256color.terminfo
#
# Usage:
#
#   export TERM=screen-256color
#
screen-256color|screen with 256 colors and italic,
        sitm=\E[3m, ritm=\E[23m,
        use=screen-256color,
  1. Execute the command:
$ tic screen-256color.terminfo
  1. Add the following lines to .vimrc:
set t_ZH=^[[3m
set t_ZR=^[[23m

NOTE: ^[ must be entered with <C-V><Esc> 3. Add the following line to .tmux.conf:

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

NOTE: It the step 3 does not work, start tmux using the following command:

$ env TERM=screen-256color tmux
@thexavier666
Copy link

Thanks! Works well.
In step 3, I put the following in .vimrc

let &t_ZH="\e[3m"
let &t_ZR="\e[23m"

which is basically the same thing

@sevillaarvin
Copy link

Don't forget to restart after step 3 (tmux config):

https://unix.stackexchange.com/a/564360

tmux kill-server && tmux

@eyev0
Copy link

eyev0 commented Mar 16, 2022

Thanks!

@mauroporras
Copy link

Does this FAQ section mean that the present Gist is not necessary anymore?:

https://github.com/tmux/tmux/wiki/FAQ#i-dont-see-italics-or-italics-and-reverse-are-the-wrong-way-round

@samuelevalperta
Copy link

For me starting tmux with "env TERM=screen-256color tmux" works. However I'd like to understand why should I set this env when even if I start tmux without doing it it's set to the same thing (but not working).

@itachi-19
Copy link

"env TERM=screen-256color tmux" worked for me as well. Don't know why this works.

@deybhayden
Copy link

"env TERM=screen-256color tmux" worked for me as well.

@blefev
Copy link

blefev commented Feb 15, 2023

@mauroporras Yes that worked. Just had to add set -g default-terminal "tmux" to tmux conf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment