Skip to content

terminfo

G. Bai edited this page Aug 14, 2021 · 8 revisions

terminfo

Terminfo is a library and database that enables programs to use display terminals in a device-independent manner.

In layman's terms, your terminal emulator uses terminfo to display CLI, or talk to tmux/Vim so they can display the text based interface.

Currently, Thomas E. Dickey maintains ncurses and the distributed terminfo database. Here are links to a table of content of terminfo database, a terminfo database, and a coloured terminfo database.

In this wiki page, all terminfo are compiled with this database with no alteration.

To get terminfo database:

$ curl -LO https://invisible-island.net/datafiles/current/terminfo.src.gz && gunzip terminfo.src.gz

The file is downloaded as a terminfo.src file. It includes basically all existent terminfo.

Inspect and compile terminfo

infocmp

To see xterm-256color terminfo:

$ infocmp -x xterm-256color

The option -x includes user-defined capabilities which begins with capital letter (e.g. curly underline Smulx).

tic

To compile database into ~/.terminfo:

$ tic -x terminfo.src

All the terminfo defined in terminfo.src will be compiled. Similar to infocmp, the option -x includes user-defined capabilities.

To compile only to one or some terminfo, into ~/.terminfo:

$ tic -xe xterm-256color,tmux-256color terminfo.src

Only xterm-256color and tmux-256color are compiled.

To compile for all users (into e.g. /usr/share/terminfo):

$ sudo tic -x terminfo.src

Interesting capabilities in terminfo

  • Italics: sitm=\E[3m entry. It's not in xterm-256color, but terminal emulators like iTerm2 enables italics in their software. It's in tmux-256color, but for iTerm2, this line needs to be added into tmux.conf:

    set -as terminal-overrides ',*:sitm=\E[3m'
    
  • Curly underline: Smulx=\E[4\:%p1%dm entry, see https://github.com/tmux/tmux/issues/1492#issuecomment-427939241. This is a user-defined capability, and needs to be enabled by terminal emulators first. kitty and iTerm2 implemented curly underline. kitty has its own terminfo xterm-kitty which includes curly underline entry. tmux-256color also has it. But it's not available in xterm-256color. Therefore, kitty can show curly underline with xterm-kitty but iTerm2 cannot show curly underline with xterm-256color, but both can display curly underline in tmux with tmux-256color, provided this line is added into tmux.conf:

    set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
    
  • Coloured underline: Setulc=\E[38\:2\:\:%p1%{65536}%/%d\:%p1%{256}%/%{255}%&%d\:%p1%{255}%&%d%;m entry, see https://github.com/tmux/tmux/pull/1771#issuecomment-500906522. This is only supported by kitty as of right now, but you do not need to add the following line to tmux.conf:

    set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
    

    Because kitty can display coloured underline in tmux without configuring it in tmux.conf. iTerm2 and Alacritty do not support coloured underline, that means when you use tmux with those two terminal emulators, coloured underline won't work even if you put that line in tmux.conf.

Ref:

Clone this wiki locally