Search code examples
tmuxgnu-screenterminal-emulatoransi-escapeterminfo

tmux man-page search highlighting


When I search in, for example, man ls while in a tmux session, the search strings don't appear highlighted - the page jumps down so that the search string is on the top line of the buffer, as expected, but it's not highlighted.

Doing the same thing in the same shell while not in a tmux session results in highlighted search strings.

I have no idea where to start looking to solve this. Any hints are appreciated.


Solution

  • Fixed it. The problem is to do with the way that the screen $TERM handles italics. From the tmux FAQ:

    vim displays reverse video instead of italics, while less displays italics (or just regular text) instead of reverse. What's wrong?

    This matches my problem exactly. The $PAGER used by man is less by default - basically, man uses less to show the contents of the manual pages. In my case, less wasn't highlighting text, just showing regular text.

    The reason for this happening:

    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.

    The solution is to make a new terminfo file for tmux, which lets it know that italics are supported. The solution's outlined in the (at time of writing) very, very bottom of the tmux FAQ.

    After creating the new terminfo file, in tmux: C-b :source-file /absolute/path/to/.tmux.conf (from this SuperUser question) - this should make tmux reload the .tmux.conf file. However, this didn't work for me, and the changes only applied after restarting the tmux server (close all tmux sessions, then re-open them).