3

I am using Debian (Jessie).

My ~/.vimrc file contains the following statement.

colorscheme murphy

My ~/.Xresources file contains the following properties.

URxvt.background: #000000
URxvt.foreground: #e0e0e0
URxvt.scrollBar: false
URxvt.borderless: true
URxvt.font:xft:Bitstream Vera Sans Mono:pixelsize=16

When I launch vim within my rxvt-unicode terminal (urxvt) I get the expected output.

Vim running within rxvt-unicode

But when I launch tmux within urxvt and then launch vim within the tmux terminal, the colours are too bright.

Vim running within tmux running within rxvt-unicode

How can I fix this?

2 Answers 2

3

The issue occurs because the rxvt-unicode (urxvt) terminal supports only 88 colours whereas tmux terminal supports 256.

Output from urxvt:

susam@nifty:~$ tput colors
88

As a result, when tmux starts, it uses only 8 colours

susam@nifty:~$ tput colors
8

Adding the following tmux command to ~/.tmux.conf doesn't help.

set -g default-terminal screen-256color

With that line in ~/.tmux.conf, when tmux starts, it seems to be using 256 colours.

susam@nifty:~$ tput colors
256

However, it doesn't help because although tmux seems to be using 256 colours, the underlying rxvt-unicode (urxvt) terminal cannot display them properly since it supports only 88 colours. As a result, Vim still displays colours that are too bright.

Solution: Install rxvt-unicode-256color package.

There is an rxvt-unicode-256color package available in Debian that comes with urxvt terminal that supports 256 colours. Installing rxvt-unicode-256color fixed the issue.

The commands I used:

aptitude update
aptitude purge rxvt-unicode
aptitude install rxvt-unicode-256color

The colours appear a little bit different now.

enter image description here

But the experience is consistent with tmux.

enter image description here

1
  • Thanks! See my answer on how to fix highlighting and italics.
    – mzuther
    Jan 11, 2015 at 14:33
0

Susam Pal's answer is great and worked for me. I still had a small issue with it, however, as man highlighted search results in italics. According to the last entry in the tmux-FAQ:

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.

Here's how to fix this issue from the terminal (adapted from the FAQ):

$ mkdir $HOME/.terminfo/
$ screen_terminfo="screen-256color"
$ infocmp "$screen_terminfo" | sed \
  -e 's/^screen[^|]*|[^,]*,/screen-it-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

Then, change the following tmux line in ~/.tmux.conf:

set -g default-terminal screen-it-256color

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.