Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a debug trap that runs every time I enter a command in bash that sets the window title to indicate what command is running. I'm leaving out all the configuration details and boil it down to:


This works incredibly well, with only one snag: if the bash shell is running in an environment that does not support this feature, the GENERATED_WINDOW_TITLE is printed on the screen with each prompt. This happens any time I'm running bash from a non-X terminal.

How can bash tell if this escape sequence is supported?

share|improve this question
I'm looking at "tput has_status_line" as a possible starting point, but all my terminals claim that this is not a known terminfo capability - despite documenting it as a boolean in terminfo. – Sniggerfardimungus Feb 26 '13 at 23:37
I've updated the blog post on this topic, in case you're interested in the fun color prompt and status line stuff I was doing with this: foodini.org/permalink.cgi?link=20080816 – Sniggerfardimungus Feb 27 '13 at 20:28
up vote 3 down vote accepted

I don't think there's a terminfo capability for that. In practice, testing the value of TERM should be good enough. That's what I do in my .bashrc and .zshrc, and I don't recall it being a problem.

case $TERM in
share|improve this answer
Heh heh. I just plugged in an "if [ $TERM == "xterm" ];" but holy cow! How did you pull that list of possibilities together? – Sniggerfardimungus Feb 26 '13 at 23:44
@Sniggerfardimungus Right now, grep -C5 title ~/.zshrc. When I wrote it (last updated 2007)… I didn't leave a comment, so by observation I guess. – Gilles Feb 26 '13 at 23:50
Thanks for the hack. I've had trouble getting it to parse, though, and went with a simpler version that I'll build up over time as I find a need for more terminals. – Sniggerfardimungus Feb 27 '13 at 20:29

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.