Server Fault is a question and answer site for system and network administrators. 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

Normally, when you load a saved session in PuTTY and connect to it, PuTTY will set the window title to the host name of the system you connected to (plus the string "PuTTY").

Now I have many different sessions that all connect to the same host, but on different ports (because the host runs several SSH tunnels on different ports). Therefore seeing the host name is not very helpful, since it's always the same.

So I'd like PuTTY to show the name of the loaded session in the window title. Is there a way to do this?

The only way I could find is to set the window title manually (Window / Behaviour / Window title). But I believe I'd have to do this manually for each session, which is rather tedious.

share|improve this question
up vote 1 down vote accepted

First of all, I'm new to Debian 8. I often say : We can not know everything but we can learn everything.


To change the PuTTY SSH session window title (one by one manually by Putty GUI):

For Windows & Debian

  1. Load a session from Putty.
  2. On left side tree menu click on: Window > Behaviour.
  3. On the right panel, in the Window title text box enter your title.
  4. Save the session.

To change the PuTTY SSH session window title (for all sessions by command line):

For Debian8

  1. Go to the folder where Putty store sessions: /home/nolwennig/.putty/sessions

  2. Assign to parameter WinTitle the saved session file name for each saved session file with something like this:

    find . -type f -exec sed -e 's/^WinTitle=/WinTitle=%f/g' {} \;

    Work fine if no WinTitle is recorded

For Windows

  1. Putty store sessions in Windows registry HKEY_CURRENT_USER\Software\Simontatham\PuTTY\Sessions

  2. You can export this section with a command like this:

    C:> regedit /e "%userprofile%\desktop\putty-registry-sessions.reg" HKEY_CURRENT_USER\Software\Simontatham\PuTTY\Sessions
    
  3. It must be possible to make a script that updates the putty-registry-sessions.reg file to change the value of WinTitle for each of saved sessions.


Sources & inspirations: http://stackoverflow.com/a/5456142/4457531 & http://stackoverflow.com/a/6739322/4457531 & http://stackoverflow.com/a/13012743/4457531 & http://stackoverflow.com/a/13023979/4457531

share|improve this answer
    
I know I can do that - it's mentioned in my question, along with why I am looking for a different solution. – sleske Dec 31 '15 at 13:34
    
I update my answer with a little script – Nolwennig Jan 4 at 14:09
    
Neat idea with the script. However, AFAIK, Putty by default stores sessions in the Windows registry. If yours uses files, you are probably using a modified version (though it might still work by exporting/importing the config). Could you mention that in the answer? – sleske Jan 4 at 14:25
    
I'm on Debian8 here, I add the location of Putty sessions storage for Windows in my answer but I can't write/test a script for that now : ( – Nolwennig Jan 4 at 15:54
    
Oh, right, forgot that PuTTY has a Linux version, too. Anyway, nice answer, thanks. – sleske Jan 5 at 10:30

The only other route I'm aware of is to use the xterm emulation features to set the title from the system you are logged into (on RedHat and Suse linux, the bash prompt is written to the titlebar by default).

See this page for a description of the process and the relevant escape sequence.

share|improve this answer

The solution below seems to solve this problem.

http://www.charlestonsw.com/putty-window-name-trick/

Hope this helps, Andy

share|improve this answer
2  
While this may answer the question, it's preferable if you can summarise the answer here as links do go dead over time. – Ladadadada May 28 '14 at 10:43
1  
This is the procedure described on that site: In the putty session setup window enable the checkbox labelled "Disable remote-controlled window title changing" found under Terminal->Features. Next give your session window a name via the Window->Behaviour dialog. Enter the title into the textbox labelled "Window title:" – BdN3504 Oct 14 '15 at 14:57

This function will set the title of your PuTTY window to the given String

# set title 
title() {
  echo -ne "\033]0;"$1"\007"
}

You can use this to set the title from the command line or from scripts, e.g. from within .bashrc.

share|improve this answer

Thanks for this lead.

I was looking for how to make window titles stick when using putty with session files.

So in .putty/sessions/ServerX set a default title and no remote behaviour as

NoRemoteWinTitle=1
WinTitle=Welcome to ServerX

and to give it a special title for some particular purpose just override the default

putty -load .putty/sessions/ServerX -title "ServerX:/var/log/messages"
share|improve this answer

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.