Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
6.0.4
share|improve this question

2 Answers 2

up vote 4 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)
HOSTNAME=${HOSTNAME%%.*}
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 at 18:19

Your Answer

 
discard

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.