How can I set PuTTY's window title to the name of the loaded session?

Solution 1:

The solution below seems to solve this problem.

1) Go to the aforementioned Window/Behaviour/Window Title setting and put in a title that makes sense to you.

2) Go to the Terminal/Features settings and check off the Disable remote-controlled window title changing box.

Setting 1

Setting 2

Solution 2:

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.


Solution 3:

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:

  • kurumi for https://stackoverflow.com/a/5456142/4457531
  • brandizzi for https://stackoverflow.com/a/6739322/4457531
  • FGreg for https://stackoverflow.com/a/13012743/4457531
  • m0nhawk for https://stackoverflow.com/a/13023979/4457531

Solution 4:

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"

Solution 5:

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 Red Hat Linux 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.

Tags:

Putty