Fixed highlighting in tmux

9,897

Solution 1

I have found info and solutions about it on tmux's pages:

Screen's terminfo description lacks italics mode and has standout mode in its place, but using the same escape sequence that urxvt uses for italics. This means applications (like vim) looking for italics will not find it and might turn to reverse in its place, while applications (like less) asking for standout will end up with italics instead of reverse.

[Fix 1] Replace terminfo entries and get reverse + italics

(per user!)

To make applications aware that tmux supports italics and to use a proper escape sequence for standout, you'll need to create a new terminfo file with modified sgr, smso, rmso, sitm and ritm entries:

$ mkdir $HOME/.terminfo/
$ screen_terminfo="screen"
$ infocmp "$screen_terminfo" | sed \
  -e 's/^screen[^|]*|[^,]*,/screen-it|screen with italics support,/' \
  -e 's/%?%p1%t;3%/%?%p1%t;7%/' \
  -e 's/smso=[^,]*,/smso=\\E[7m,/' \
  -e 's/rmso=[^,]*,/rmso=\\E[27m,/' \
  -e '$s/$/ sitm=\\E[3m, ritm=\\E[23m,/' > /tmp/screen.terminfo
$ tic /tmp/screen.terminfo

And tell tmux to use it in ~/.tmux.conf:

set -g default-terminal "screen-it"

If your terminal supports 256 colors, use:

$ screen_terminfo="screen-256color"

instead of "screen". See the FAQ entry about 256 colors support for more info. Also note that tmux will still display reverse video on terminals that do not support italics.

If your urxvt cannot display italics at all, make sure you have an italics capable font enabled, for example, add to ~/.Xdefaults:

urxvt.italicFont: xft:Bitstream Vera Sans Mono:italic:autohint=true

[Fix 2] Simply replace italic control characters with reverse

Add this terminal override to ~/.tmux.conf:

set -g terminal-overrides 'rxvt-unicode*:sitm@,ritm@'

Solution 2

I run urxvt in arch linux. The op's answer did not help me. This helped me:

https://github.com/tmux/tmux/blob/2.1/FAQ#L355-L383


search for italic and run that; then, put this in tmux config

set -g default-terminal "tmux"

don't use "tmux-256color". (try it, I suppose, but it didn't work for me.)


finally, add this to your rc (.zshrc, .bashrc, etc):

export TERM="xterm-256color"

Solution 3

Quicker way:

set -g terminal-overrides "screen.xterm-new"

Works without any further magic (and still heeds the warning in the tmux manual about the terminal type needing to be "screen" or a derivative thereof).

Share:
9,897

Related videos on Youtube

Luca Piciullo
Author by

Luca Piciullo

Some of my social profile pages: Profession: LinkedIn Open Source: Open HUB Gamification: CodinGame, Codewars, HackerRank

Updated on September 18, 2022

Comments

  • Luca Piciullo
    Luca Piciullo over 1 year

    I miss highlighting (reverse mode) on console since I started to use urxvt + tmux as main terminal. The highlights was replaced with with italic font - what looks pretty cool at first - however I can't find the one italic word in thousands non-italic when I try to search something in a less.

    This is works properly while the terminal type is set to an xterm* profile (with e.g. set -g default-terminal "xterm-color" in .tmux.conf). However some shortcut can't works, apps can't get proper geometry of terminal, ... in this case.

  • user1338062
    user1338062 almost 9 years
    Fix 1 seems to work, but it's 2015, can this really be so difficult?
  • Luca Piciullo
    Luca Piciullo almost 9 years
    Unfortunately, I can not find any better solution for this issue + I have stopped searching when I found this on a tmux mailing list... :(
  • user1338062
    user1338062 almost 9 years
    Well, according to tmux FAQ tmux 2.1 should fix the behavior. So I guess this is only needed temporarily. I personally just did what the OP said and set my default-terminal to xterm.
  • Luca Piciullo
    Luca Piciullo almost 9 years
    Sometimes this is not soo good. E.g. when you have to compatible with PuTTY you can not use xterm, only screeen variants.
  • Feuermurmel
    Feuermurmel over 8 years
    @user1338062 Yes, this is really sad, especially considering that tmux could just provide its own terminfo entry, like screen did for ages.
  • Benjamin W.
    Benjamin W. over 8 years
    Fix 1 worked for me, but made my solarized dircolors disappear; I was able to fix it by adding TERM screen-it to the list of terminals in ~/.dircolors.
  • Tino
    Tino almost 8 years
    Works for me perfectly, for example watch -n10 -d COMMAND args.. allows to detect changes now (like blanks! How do you do italic blanks?). I think this should be the accepted answer. Note: When terminal already is open, use TERM=screen.xterm-new; export TERM
  • jftuga
    jftuga about 4 years
    This is working for me in 2020 with tmux 1.8 andPutty 0.73.