Why am I seeing only 8 colors in terminal (xfce-terminal)?

ReneFroger picture ReneFroger · Oct 11, 2013 · Viewed 7.8k times · Source

I'm running Xubuntu 13.04 and I want to use Vim as my default editor for everything. I have downloaded many vim color schemas and tried them out, but all of them don't look like the official screenshot.

For example, vim's own color schema - desert should look like this:

enter image description here

But in my vim, many colors won't display, for example the background.

enter image description here

So this means a fighting with xfce's Terminal and I can't force it to use 256 colors. the command tput colors gives me 8.

At the same time the code for ((x=0; x<=255; x++));do echo -e "${x}:\033[48;5;${x}mcolor\033[000m";done shows me nice colors. it seems i missed something. If I run

 **$ echo $TERM**

I get xterm. It should be 'xterm-256color'

When I try set term=xterm-256color and export TERM=xterm-256color

Then: echo $TERM

I get the message xterm-256color.

But after signout/signup, I'm still not getting the right colors in Vim. And I see the Xterm is changed to xterm again.

I added:

if $TERM == "xterm-256color" set t_Co=256 endif

and

t_Co=256

to my .vimrc file and it didn't seem to help. Then I customized the xterm entries; added this to ~/.Xdefaults:

 *customization: -color
 XTerm*termName: xterm-256color
Add this to ~/.xsession to apply to new terminals:

if [ -f $HOME/.Xdefaults ]; then
   xrdb -merge $HOME/.Xdefaults
fi

When I changed in preferences of terminal, emulate terminal environment, the 'xterm' to 'xterm-256color'

I get the message:

 '*** VTE ***: Failed to load terminal capabilities from '/etc/termcap' 

When I check /usr/share/vte/termcap/xterm, the file xterm-256color is missing. Same in folder xterm0.0. I tried to find this file on internet to download and put in the folder, but I couldn't find it.

This is driving me crazy the whole day... Have anyone suggestions?

Answer

maki57 picture maki57 · Apr 1, 2015

Quick (Temporary) Way

Enter this whenever you open a new terminal:

export TERM=xterm-256color

Works for as long as the window is open.

Works-but-dirty Way

Append the line above to ~/.bashrc.

The problem with that, though, is that editing $TERM in .bashrc is a bad idea because doing that automatically makes any terminal using bash try to use it regardless of whether it actually supports 256 colors or not (like when SSH-ing or accessing the terminals with Ctrl+Alt+F1 to F6).

What I did, though is that since xfce4-terminal sets the $COLORTERM value to xfce4-terminal, I, instead appended the following to .bashrc:

if [ "$COLORTERM" == "xfce4-terminal" ] ; then
    export TERM=xterm-256color
fi

That way, the relevant $TERM edit only happens if you're using xfce4-terminal, which just sets it to xterm anyway (and changing the emulation environment results in that "VTE" message).

References: