Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

thexavier666 commented Aug 31, 2020

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

sevillaarvin commented Nov 18, 2021

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

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

tmux kill-server && tmux

@edementyev
Copy link

edementyev commented Mar 16, 2022

Thanks!

@mauroporras
Copy link

mauroporras commented Mar 20, 2022

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

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