tic doesn't read from STDIN and segfaults when adding terminfo to support italics in tmux

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'

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