You are not logged in.

#1 2014-01-12 09:09:38

sbs
Member
Registered: 2014-01-12
Posts: 5

[SOLVED] Xfce4 terminal: how to correctly set $TERM to xterm-256color

I am using the xfce4 desktop environment, and specifically the xfce4 terminal emulator.  By default, the terminal emulator sets the "$TERM" environment variable to "xterm" rather than "xterm-256color" even though it supports 256 colors (the file /usr/share/terminfo/x/xterm-256color exists on my system). 

As far as I can tell, this is a long-standing bug in xfce/gnome terminal:
    https://bugs.archlinux.org/task/21007
    https://fedoraproject.org/wiki/Features … _Terminals
    https://bugzilla.gnome.org/show_bug.cgi?id=640940
    https://bugs.launchpad.net/xfce4-terminal/+bug/778801

The problem is that some applications, like vim, will not support 256 colors unless "$TERM" is correctly set to "xterm-256color" or something equivalent.  This causes vim to be stuck with an annoyingly-limited color scheme. 

Some people recommend manually setting the "$TERM" environment variable in the shell initialization script, like ~/.bashrc or ~/.bash_profile:
    http://vim.wikia.com/wiki/256_colors_in_vim
    http://forums.opensuse.org/showthread.p … workaround

However, other people warn that having the shell itself set "$TERM" is a bad idea, especially if using ssh:
    http://blog.sanctum.geek.nz/256-colour-terminals/

The ideal solution is to have the terminal emulator set the "$TERM" environment variable.  On another machine running the Mate desktop environment, I have been able to get the gnome-terminal to set "$TERM" when it launches by using the Run-A-Custom-Command-Instead-Of-My-Shell option in the preferences.
    http://wujingyue.blogspot.com/2012/06/l … t-256.html


My question is: how can I get the xfce4 terminal emulator to correctly set "$TERM" to "xterm-256color"?


I have tried changing the emulation setting to "xterm-256color" in the xfce4 terminal dialog: Preferences->Compatibility->"Emulation setting", but it fails with the message:
        "*** VTE ***: Failed to load terminal capabilities from '/etc/termcap'"


I have tried to add the following line to an ~/.Xresources file:

xterm*termName: xterm-256color

as suggested in the Xterm ArchWiki,
and forcing xfce4 to read in the ~/.Xresources file by adding the following line to an ~/.xinitrc or ~/.config/xfce4/xinitrc file:

[[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources

After a reboot, "$TERM" is still set to "xterm".

So far, the only thing that works is manually setting "$TERM" in my ~/.bashrc, which I would rather not have to do.  Thanks ahead of time, for anyone who can help.

Last edited by sbs (2014-01-30 11:52:18)

Offline

#2 2014-01-12 14:14:42

jv2112
Member
Registered: 2011-07-23
Posts: 154

Re: [SOLVED] Xfce4 terminal: how to correctly set $TERM to xterm-256color

case "$TERM" in
       xterm*) TERM-xterm-256color
esac 

I added this to my ~.bashrc.


Life is pleasant. Death is peaceful. It's the transition that's troublesome. Isaac Asimov - / -  My Pastebin

Offline

#3 2014-01-12 15:01:21

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [SOLVED] Xfce4 terminal: how to correctly set $TERM to xterm-256color

Unfortunately, termcap is obsolete: Arch uses terminfo.  There is a termcap lib, updated 2011, in the AUR.  I use neither Xfce nor its terminal, so I can't really give you more information.

Offline

#4 2014-01-12 18:11:10

sbs
Member
Registered: 2014-01-12
Posts: 5

Re: [SOLVED] Xfce4 terminal: how to correctly set $TERM to xterm-256color

jv2112 wrote:
case "$TERM" in
       xterm*) TERM-xterm-256color
esac

Hi jv2112.  Did you mean "TERM=xterm-256color"?  Note the equal sign.

Currently I have this in my ~/.bashrc, and it works okay:

if [ -e /usr/share/terminfo/x/xterm-256color ] && [ "$COLORTERM" == "xfce4-terminal" ]; then
    export TERM=xterm-256color
fi

But, again, I would rather not have to do this.

Offline

#5 2014-01-12 18:46:27

sbs
Member
Registered: 2014-01-12
Posts: 5

Re: [SOLVED] Xfce4 terminal: how to correctly set $TERM to xterm-256color

thisoldman wrote:

There is a termcap lib, updated 2011, in the AUR.

Hi thisoldman.  After some more research, I am a little reluctant to try to change the xfce4-terminal emulation setting.

The Xfce docs specifically recommend NOT changing it to anything other than "xterm". 

To quote the docs:
    "This specifies the terminal emulation. This does not only set the $TERM value, but also the input conversion of the VTE widget. By default this is set to xterm, if changed /etc/termcap will be read to get the emulation values.
If you have an application that needs $TERM for correct functionality, it is better to set this manually in your ~/.bashrc file (or whatever shell you use) and set the terminal emulation as xterm to avoid incorrect characters in the Terminal."


A user (Yves-Alexis Perez) in this bug report also warns against changing the xfce terminal emulation setting:

    "In any case, messing with emulation is very error prone and can break the terminal. Messing with TERM is not really that bad (although it can leads to some surprising results)."

He also says that it is not even possible right now due to a bug in vte.

Offline

#6 2014-01-14 01:09:58

jv2112
Member
Registered: 2011-07-23
Posts: 154

Re: [SOLVED] Xfce4 terminal: how to correctly set $TERM to xterm-256color

Yes. typo.


Life is pleasant. Death is peaceful. It's the transition that's troublesome. Isaac Asimov - / -  My Pastebin

Offline

#7 2014-01-30 11:50:57

sbs
Member
Registered: 2014-01-12
Posts: 5

Re: [SOLVED] Xfce4 terminal: how to correctly set $TERM to xterm-256color

I found a solution.  It requires launching the terminal emulator with a custom environment variable, similar to what I was able to achieve in the Mate desktop environment following the instructions here:  http://wujingyue.blogspot.com/2012/06/l … t-256.html

There are two steps to get this working in Xfce4.

1. Copy the system terminal .desktop file to the local config directory.

cp /usr/share/applications/xfce4-terminal.desktop ~/.local/share/applications/xfce4-terminal.desktop

and edit the following two entries:

Exec=xfce4-terminal
Terminal=false

with:

Exec=env TERM=xterm-256color /bin/bash
Terminal=true

2. This will correctly set the $TERM environment variable when the terminal emulator is launched from the Xfce applications menu, but not when launched from the default panel launcher.

On my system, the panel launcher for the terminal emulator was defined in a .desktop file in the directory ~/.config/xfce4/panel/launcher-*,  where "*" is a number, which by default was being called with the commands:

Exec=exo-open --launch TerminalEmulator
Terminal=false

I could not figure out how to combine "exo-open" with "env", or any other way to set an environment variable with "exo-open", so I also replaced  the two .desktop entries with:

Exec=env TERM=xterm-256color /bin/bash
Terminal=true

and now everything works as expected.

Offline

#8 2014-01-30 12:13:42

brebs
Member
Registered: 2007-04-03
Posts: 3,408

Re: [SOLVED] Xfce4 terminal: how to correctly set $TERM to xterm-256color

Also see older thread.

I wonder, is xterm-256color better than gnome-256color, since xfce4-terminal uses VTE, which is a Gnome project?

Edit: I've been using gnome-256color for years. I'll try xterm-256color, to see if there are any noticeable differences.

Edit2: xterm-256color seems fine, can't see any problems or differences.

Last edited by brebs (2014-03-11 10:25:40)

Offline

#9 2014-01-30 21:47:44

sbs
Member
Registered: 2014-01-12
Posts: 5

Re: [SOLVED] Xfce4 terminal: how to correctly set $TERM to xterm-256color

brebs wrote:

I wonder, is xterm-256color better than gnome-256color. . .

I don't know which is better.  There are quite a few differences listed by infocmp:

infocmp -d gnome-256color xterm-256color

Offline

Board footer

Powered by FluxBB