Change putty title window?

Is it possible to change the putty window title from a Unix command line?

Not to my knowledge. See, the client is just a window on the Windows system where you are logged in. The unix server has nothing to do with the window properties of the putty session.

Right click the putty title bar and click change settings.Expand window and click appearance and write the text which you want to appear in the windows title text box.

OP had asked for a solution to change it through the command line
and as blowtorch said it shouldnt be possible either.

Good to have the alternative through the client, if not through the command line.

That seems to be a broken link! :confused:

( 404 )

Yes it is, but depends on your shell. Just add this to your .profile, for ksh:

export SERVER=$(hostname)
case "$TERM" in
xterm*|rxvt*)
    PROMPT_COMMAND="\033]0;${SERVER}\007"
    echo $PROMPT_COMMAND
    ;;
*)
    ;;
esac

This will write the server's hostname on the title bar when you log in.
Regards.

I noticed that after posting, so have deleted it.

Yes it is. See my posting http://www.unix.com/showthread.php?t=35518 . See functions "wt" and "it". My example is for bash, but the functions are copied verbatim from my .kshrc file. So you can do it from bash or ksh.

Once you put one of the functions (eg, "wt") in your startup script (or put it in a file called "wt", or just enter it directly in your command line), you can do:

wt "Here is my NEW title"

and it will put "Here is my NEW title" in your putty window's title bar.

This makes it easy to do Fancy Shell Tricks like setting your window titlebar to be your hostname, pathname, username, silly joke, or whatever you want, dynamically.

I double checked using Putty 15 seconds... no 17... no 20... no 24... no, ...well, anyway, just now, and I can guarantee that it's more than doable. It's being done! :cool:
-Mschwage
P.S. If you do copy-n-paste my functions, make sure you turn ^[ into a real Escape character, and ^G into a real control-G character. Do that in vi by:

  • deleting the two characters
  • hit escape key
  • hit i (for insert mode)
  • hit Control-V keypair
  • Hit Escape key for ^[, or hit Control-G keypair for ^G
  • Hit the escape key again. Voila'! You've inserted a control-character.
  • Inserting a control character in your command line is left as an exercise for the reader. :stuck_out_tongue:

Thank you Mschwage - Your well documented suggestion worked very well.

Grial, thank you for your help as well, but I wasn't able to get your suggestion to work.

mschwage, thanks for that bit of code.

I am new to this forum and hope I am placing this in the correct spot....

I have implemented the solution mschwage described in his post; ie

wt ()
{
echo -n "[1]2;${@}^G"
}

This method is awesome!!!!

The reason I am posting this message is to get your assistance with another issue I am runing into in respect to the window title.

This issue is - after putty'ng to system (A) the window title changes appropriately... While logged into system (A) I run "ssh user@B" via the command line. This now changes the title to system (B)'s name. So far everything works as expected, until I exit system (B). The result is the the window title still reflects system (B).

How do I get the window title to change back to system (A) on exiting system (B)? I'd like this to be automated.

Thanks!!!!


  1. ↩︎

Perhaps write another function, e.g. myssh, to run ssh (pass in parameters) and then call wt to reset the window title.

Thanks, this will work but I was looking for something that was more transparent to other users. The idea of SSH as an alias was mention by "Smiling Dragon". I think this would work but I'd have to test it out.