Setting the TERM environment variable

Asked by Tin Tvrtkovic on 2013-09-08


I'm trying to get Terminator to set my TERM environment variable to 'xterm-256color' and failing. I'm using Ubuntu 13.04 (latest stable).

I'm using the BZR tip, which I expected to work after was merged in.

So, after setting the term variable in my config, I investigated with the following in the Terminal class, __init__:

dbg("Configured TERM is " + self.config['term'])
os.environ['TERM'] = self.config['term']
dbg('TERM is ' + os.getenv('TERM'))

(I changed putenv to a direct assignment to os.environ, as suggested by the Python docs). The result of this is:

tin@tin-desktop:~/pg/terminator$ ./terminator -d 2>&1 | grep TERM
Terminal::__init__: Configured TERM is xterm-256color
Terminal::__init__: TERM is xterm-256color

but doing an 'echo $TERM' in the resulting terminal still shows xterm. As far as I can see nothing is assigning to TERM in .bashrc, and 'echo $TERM' at the top of .bashrc prints out 'xterm'.

I'm making this a question since I'm not at all sure if this is an issue with Terminator or with my particular set-up. Could someone suggest additional steps to debug this, or shed some more light on what exactly is happening here?

Question information

English Edit question
Terminator Edit question
No assignee Edit question
Solved by:
Stephen Boddy
Last query:
Last reply:

Hi Tin,


Looks like this is a limitation with the vte widget that is used. It falls back to xterm, ignoring the passed env var, and it looks like you would need to work around it in bashrc (as per ).

I don't think it's fixable in the Terminator code. I even did a quick forced set_emulation call, which tosses an error because there's no termcap file. All a bit confusing and busted I'm afraid.

Tin Tvrtkovic (tinchester) said : #2

Hi Stephen,

thanks for the info. Playing around, yeah, seems the real problem is in the spawn_child method of the Terminal class, which invokes vte.fork_command. I'm unable to find the docs for the Python bindings (bleh), but the C docs for my version (0.28) clearly state: The "TERM" environment variable is automatically set to reflect the terminal widget's emulation setting. So the code adding the TERM variable to the list of env. vars passed to fork_command basically does nothing and should probably be reverted and comments inserted linking back to this question or another resource.

Tin Tvrtkovic (tinchester) said : #3

Thanks Stephen Boddy, that solved my question.