I discovered through this answer that I've been setting terminal colours in my prompt in a naive way for years.

I've now modified my .bashrc to use 'tput' commands to colourise various elements of my prompt. The one remaining escape code I have is this:

TITLEBAR="\[\033]2; PROD - \u@\h:\w \007\]"

Does anyone know if there is a tput/terminfo attribute I can use to set the title bar of my terminal window, so that I can eliminate that escape?


The actual capabilities are tsl (To Status Line) and fsl (From Status Line), but of course not all terminals have then. In Linux in particular you need to set your terminal to xterm+sl or something similar.

You can test this with

export TERM=xterm+sl
echo `tput tsl` Hello world `tput fsl`; sleep 10

I wouldn't bother and keep those escapes in .bashrc

  • 1
    Seems my copy of Ubuntu lacks that terminal info. :( I blame incomplete terminfo files :) – David Pashley Jun 11 '09 at 12:16
  • 1
    screen, however, appaears to support them just fine. Thanks! – Murali Suriar Jun 11 '09 at 12:26
  • \033]; is the escape sequence in xterm for an "Operating System Command". I don't know how to do that in tput, but if it is possible to do via tput that would be a better method for cross platform terminal title setting. E.g. on xterm, it would result in the sequence \033]0;Title\007. See also here – Wyatt8740 Mar 23 '18 at 17:09

Having looked at the xterm terminfo file, I can't find any code that is identical to this command, so I suspect there is not.

If you're interested, the terminfo man page lists all the commands that termcap and terminfo understand. I decompiled the terminfo database file using:

# infocmp -L xterm 

I can't comment, thus an extra answer:

If you use tsl/fsl, be sure to ask the terminal for hs first. hs should be true if tsl/fsl (and other *sl) are supported.

tput hs && { echo ....; }
  • +1 if you have a reference for this. – l0b0 Mar 21 '12 at 8:28

For more info on xterm's "vt100 mode" special features, see the Xterm Control Sequences document in the Operating System Controls section for all the gory details.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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