Putty has the ability to change the title window to the name of the server that you're connecting to. That's the basic behavior and intent. It's very useful.
But what happens if you're on server number 1 and connect to server number 2 and it sets the title based on it's PS1 environment variable and it's a shared server or you can't change the remote server at all?
GRRR!:

You could set this manually easily:

and then use the following function so the title does not change:
Disable remote controlled window title changing:

However that is a manual process and can get tedious after a while. There is a way to automate this.
Putty keeps most all of it's options in the registry. So what we need to do is to create a script will put in the correct options.
Specifically we're looking at two options under the following hive:
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\SessionName]
Where SessionName is the name of your Saved Session.
The first is
"WinTitle"=""
Here you can set any title you like like so:
"WinTitle"="MyServer"
Simple Enough.
The second is
"NoRemoteWinTitle"=dword:00000001
Here you can set whether the remote side can control window title changing.
Set to 00000001 for NO (as we set in the screenshot above )
Set to 00000000 for Yes
This is one solution that I use:
First I created a new putty session and just call it "blank" and manipulate that.
I created a small batch file that creates a .reg file with all this info for us, silently imports the file, and then starts up putty with the newly titled window that won't change its title:
@echo off
set file=blank.reg
set title=%1
set profile=blank
echo Windows Registry Editor Version 5.00 > %file%
echo. >> %file%
echo [HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\%profile%] >> %file%
echo "WinTitle"="%title%" >> %file%
echo [HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\%profile%] >> %file%
echo "NoRemoteWinTitle"=dword:00000001 >> %file%
regedit /s %file%
start putty -load %profile%
exit
So I just name it new_putty.bat and run "new_putty.bat MyServerName" from the windows command line and Bingo!



0 comments:
Post a Comment