5

I'm trying to follow these instructions to add italics support to tmux.

1) I tried running copying-pasting and running this command

cat <<EOF|tic -x -
    tmux|tmux terminal multiplexer,
        ritm=\E[23m, rmso=\E[27m, sitm=\E[3m, smso=\E[7m, Ms@,
        use=xterm+tmux, use=screen,

    tmux-256color|tmux with 256 colors,
        use=xterm+256setaf, use=tmux,

but that gives me:

tic: Can't open -

I'm guessing this is because OS X's tic doesn't support reading from stdin.

2) I then tried saving the terminfo to a temporary file named tmux.terminfo and ran it using tic -x tmux.terminfo

tmux|tmux terminal multiplexer,
    ritm=\E[23m, rmso=\E[27m, sitm=\E[3m, smso=\E[7m, Ms@,
    use=xterm+tmux, use=screen,

tmux-256color|tmux with 256 colors,
    use=xterm+256setaf, use=tmux,

However, I get this error message

[1]    32091 segmentation fault  tic -x tmux.terminfo

3) I also tried running tic without the -x flag, so that it doesn't treat unknown capabilities as user-defined.

That gives me this:

"tmux.terminfo", line 2, col 62, terminal 'tmux': unknown capability 'Ms'
[1]    35607 segmentation fault  tic tmux.terminfo

I'm on OS X 10.11.6.

1
  • 1
    You're right, OS X's tic doesn't read from stdin. tic is looking for definitions for xterm+tmux and xterm+256setaf, and it can't find them, so it segfaults (unfortunately). You could try a newer terminfo.src which includes these. mkdir ~/.terminfo; gunzip terminfo.src.gz; export TERMINFO=~/.terminfo; tic -x -e tmux terminfo.src; tic -x -e tmux-256color terminfo.src.Having said all that, I'm not sure if italics are supported in Terminal/iTerm2...
    – mtklr
    Commented Aug 14, 2016 at 14:56

2 Answers 2

9

So this works for me, notice I edited use like @mtklr suggested:

# A screen-256color based TERMINFO that adds the escape sequences for italic.
# run to add to term db: tic tmux.terminfo
tmux|tmux terminal multiplexer,
  ritm=\E[23m, rmso=\E[27m, sitm=\E[3m, smso=\E[7m, Ms@,
  use=xterm, use=screen,

tmux-256color|tmux with 256 colors,
  use=xterm-256color, use=tmux,

Then tic -x tmux.terminfo

Shouldn't have errors

Then added to .tmux.conf:

set -g default-terminal "tmux-256color"
set -as terminal-overrides ',xterm*:sitm=\E[3m'
2
  • use=xterm and use=xterm-256color have undesirable side effects since it changes all the keys around. The definitions of xterm+256setaf and xterm+tmux are like one line, it'd be better to just include them. And that wasn't even what @mtklr suggested.
    – Random832
    Commented May 11, 2017 at 20:38
  • this one also worked for me with iTerm2, tmux (both with native iTerm2 integration and without) and Neovim. Commented Nov 2, 2023 at 20:51
4

The above solution didn't work for me, however, this did:

1. Create two files:

File xterm-256color-italic.terminfo:

# A xterm-256color based TERMINFO that adds the escape sequences for italic.
xterm-256color-italic|xterm with 256 colors and italic,
  sitm=\E[3m, ritm=\E[23m,
  use=xterm-256color,

File tmux-256color-italic.terminfo:

# A xterm-256color based TERMINFO that adds the escape sequences for italic.
tmux-256color-italic|tmux with 256 colors and italic,
  sitm=\E[3m, ritm=\E[23m,
  use=xterm-256color,

2. tic them both

tic xterm-256color-italic.terminfo
tic tmux-256color-italic.terminfo

3. Tell your terminal to use xterm and tmux to use tmux with overrides.

Figure out how to set your terminals $TERM variable to xterm-256color-italic. In iTerm it's in Prefs -> profiles -> Terminal -> Report Terminal Type.

In your .tmux.conf file:

# tmux display in 256 colours
set -g default-terminal "tmux-256color-italic"
#  enable terminal compatibility with outside terminal
set-option -ga terminal-overrides ",xterm-256color-italic:Tc"

4. Test for italics and colour

# Test Italics
echo `tput sitm`italics`tput ritm`
# Test Colour (should be smooth gradient)
awk 'BEGIN{
    s="/\\/\\/\\/\\/\\"; s=s s s s s s s s s s s s s s s s s s s s s s s;
    for (colnum = 0; colnum<256; colnum++) {
        r = 255-(colnum*255/255);
        g = (colnum*510/255);
        b = (colnum*255/255);
        if (g>255) g = 510-g;
        printf "\033[48;2;%d;%d;%dm", r,g,b;
        printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
        printf "%s\033[0m", substr(s,colnum+1,1);
    }
    printf "\n";
}'

If I understand correctly tmux depends on an external terminal environment in order to render text correctly. This means it needs to translate/override certain commands.

source: https://github.com/tmux/tmux/issues/696

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .