PuTTY – How to Set PuTTY’s Window Title to Loaded Session Name

putty

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.

Best Answer

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

For Windows & Debian

  1. Load a session from PuTTY.
  2. On left side tree menu, click on: WindowBehaviour.
  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 Debian 8 (Jessie)

  1. Go to the folder where PuTTY stores sessions: /home/nolwennig/.putty/sessions

    Note: replace nolwennig with your username

  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' {} \;

    It works fine if no WinTitle is recorded

For Windows

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

    Note: not replace SimonTatham with your username.

  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 the saved sessions.


Sources & inspirations: