Super User is a question and answer site for computer enthusiasts and power users. 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

In the PuTTY configuration there's an option in Terminal->Features called Disable remote-controlled window title changing. Without that enabled, the title bar of PuTTY will change every time I press return in the console.

I was thinking it'd be a more clean solution to set the title bar text from Linux than to specify one for every PuTTY client I have laying around. So where can I modify what Linux sets as the window title?

$ uname -a
Linux drevo 2.6.32-5-amd64 #1 SMP Mon Jan 16 16:22:28 UTC 2012 x86_64 GNU/Linux

$ cat /etc/debian_version
share|improve this question
up vote 5 down vote accepted

Most terminal programs - including konsole, putty and xterm - emulate the old VT100 terminal. This terminal allows you to set certain things, including bold, colors, setting the terminal title, and so on, using special character sequences called escape sequences.

The bash shell has a variable called PROMPT_COMMAND which, if set, is evaluated before every prompt you print out (I believe zsh has something similar, in fact I think bash took the code from them). You can output escape sequences in PROMPT_COMMAND and it will set your title bar.

This is what I have in mine (Linux/bash):

USER=$(/usr/bin/id -un)
HOSTNAME=$(uname -n)
PROMPT_COMMAND='echo -ne "\e]0;$USER@${HOSTNAME}: $(pwd -P)\a"'

You can put this in your ~/.bashrc

There are a lot of customizations you can do with your terminal. I like bold in my prompt, to make it easier to see the end of my prompt. This makes it bold yellow, good against my default black background:

PS1="\[\e[33;1m\]\h:\$\[\e[0m\] "

Look around for Linux Prompt Customization, you'll find more HowTos than you'll know what to do with. Pick the one that you find easiest to read.

share|improve this answer

The terminal title is set by using special escape sequences in the console output. By default, the bash prompt includes these escape sequences and sets the title to the current working directory.

So you will have to edit your PS1 variable (most of the time it's set in ~/.bashrc), otherwise bash will overwrite your title every time the prompt is displayed.

You can then set the title by putting the following in a script that gets executed when you log in, e.g. ~/.profile:

echo -e "\033]0;<your string>\007"
share|improve this answer
Note, this the only one that answers the question. – Erik Aronesty Nov 19 '14 at 18:19
Change -e to -en if you want to avoid the extra blank line that is output by the echo command. – ADTC Jun 6 at 8:06

I have searched many forums and I haven't found the answer for the question:
How to get all command output to Putty title?

Needed it for other programs to know when some jobs on a server is done and is it done right or wrong. Plink stdout and stdin wasn't working. I used many tweaks with wait delays and for some commands that worked, for others not. XSEL and XCLIP couldn't be installed on that server.

So here is the solution:

  1. Get command output in a file.
  2. Echo that file to title.

On Putty client and SUSE server it looks like this:

ls /home | grep domagaja > logutoit.txt 
echo -e "\033]0\\;$(cat logutoit.txt)\\007\\c"

Hopefully someone will be able to use this. It won't work for all server types and putty client settings, of course, but the idea should work well.

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.