Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

On a clean install of Ubuntu 12.10, the default gnome-terminal is reporting $TERM to be xterm where it should really be reporting xterm-256color. What is the best way of changing this? I'm avoiding putting this in my .bashrc as that's just asking for trouble.

share|improve this question
Care to explain why xterm is wrong? Afaik we all have xterm. Besides that: also care to explain why putting this in bashrc is asking for trouble? –  Rinzwind Dec 27 '12 at 16:19
xterm is wrong because most applications won't work in 256-color mode unless it's xterm-256color or screen-256color (vim and tmux being the main ones I care about). Like @Freddy I would prefer not to set these in my shell profile, because I may be connecting from a different terminal type over SSH, and because it's really the terminal emulator's job to set this. I'm amazed that gnome-terminal doesn't provide multiple emulations. –  Jim Stewart Mar 31 '13 at 2:48

2 Answers 2

While it's true that terminfo has xterm+256color (/usr/share/terminfo/x/xterm+256color), termcap has just xterm (/usr/share/vte/termcap/xterm), so changing $TERM shouldn't be advisable.

Anyhow, $TERM is not set by gnome-terminal, but by vte. The default value for that environment variable can be changed either at compile time (giving an option to the configure script) or by calling the vte_pty_set_term() function. Looking at the sources of gnome-terminal, I see that vte_pty_set_term gets never called, so I can say that there are no ways to modify $TERM editing gnome-terminal's settings.

What you have to do is to place the following piece of code in your ~/.profile:

if [ "x$TERM" == "xxterm" ]
    export TERM=xterm-256color
share|improve this answer

For connecting with a terminal that's not able to do 256 colors.

It'd be far better to detect the terminal specifically with $COLORTERM. Look for gnome-terminal, xfce4-terminal, etc, and then set the $TERM variable to xterm-256color.

I do it with:

if [ "$COLORTERM" == "gnome-terminal" ] || [ "$COLORTERM" == "xfce4-terminal" ]
    elif [ "$COLORTERM" == "rxvt-xpm" ]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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