Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have several servers that have the same prefix in their name: mail.servername. When I have several sessions open (I use PuTTY from Windows 7), it is a minor PITA to figure out which one is which since PuTTY names the windows user@mail and the command line displays user@mail:~$ for all of them.

Is there a way to have the full server name displayed? I don't have the option of changing the servers' names.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Think what you are looking for for changing the PuTTY window title is this: PuTTY allows the server to send xterm control sequences which modify the title of the window in mid-session. From the putty manual.

How to actually do it, point your favorite text editor to ~/.bashrc Locate the lines that say:

case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

Then change:

PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$'

to:

PS1='\[\e]0;\u@YOUR MODIFIED TINGY: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$'

Save and be happy. If you wanna test it before doing the final change, use export PS1='all the stuff'

share|improve this answer
    
This worked, but I changed the ' to " from your example (which you actually used in the first code block). Also, I just want to confirm that the line is supposed to end with $ - I am suspicious whenever I see that as I worry it is from a copy & past out of a session, indicating the line goes beyond the window. –  Paul Nov 27 '13 at 1:10
1  
@Paul you shouldn't need to replace the single quote by a double one although that doesn't make a difference in that case. The last $ is the standard non root user prompt, you should replace it by # if you are root. Usually, a space is following it for better readability but is missing here. –  jlliagre Nov 27 '13 at 1:38
    
Thanks! I assume if I make the same change in /root/.bashrc the display will remain the same for root sessions? –  Paul Nov 27 '13 at 3:02

Use this command

printf "\033]2;%s\a" $(</etc/hostname)

to have the server name displayed in the Putty window title bar.

share|improve this answer
    
/etc/hostname is the fqdn, which is reduced to mail. Pasting your command into a session does not seem to change anything. –  Paul Nov 27 '13 at 0:16
    
Answer updated to use /etc/hostname instead of the hostname command –  jlliagre Nov 27 '13 at 0:48
    
I tried using /etc/hostname and still nothing. The answer from Anders F. U. Kiær provides a more permanent solution and worked on the first try, but thank you for your response. –  Paul Nov 27 '13 at 1:07
    
Are you sure the /etc/hostname file contains mail.servername and not just mail ? You can of course put this line in .bashrc for the name to be set automatically. –  jlliagre Nov 27 '13 at 1:28
    
Yes, I checked before posting the comment (I'm just like that). –  Paul Nov 27 '13 at 1:47

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.