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.
Based on Less Colors For Man Pages by Gen2ly
, here is my man page and how to do it:
This is a shell, not a web page !
Edit your ~/.bashrc
~/.zshrc
, etc. to add :
# Colored man pages: http://linuxtidbits.wordpress.com/2009/03/23/less-colors-for-man-pages/
# Less Colors for Man Pages
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\E[01;38;5;74m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # end mode
export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
export LESS_TERMCAP_so=$'\E[38;5;016m\E[48;5;220m' # begin standout-mode - info box
export LESS_TERMCAP_ue=$'\E[0m' # end underline
export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline
Reload your config and try a man page search :
. ~/.bashrc && man ls
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).
This thread is a few years old but is still the one that comes up as the best search result, so I'm answering with what finally worked for me. This is based off of tmux FAQ.
...but the instructions aren't completely clear on when or where to substitute the -256color string. I use gnome-terminal (v 3.16.2) with tmux, and this worked for me:
$ mkdir $HOME/.terminfo/
$ screen_terminfo="screen-256color"
$ infocmp "$screen_terminfo" | sed \
-e 's/^screen[^|]*|[^,]*,/screen-256color|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-256color"
Note: I tried it once without the -256color and since that didn't work (still seeing italics instead of highlighting), I had to delete everything under the .terminfo dir (another dir called 's') before the infocmp would work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With