function wtitle {
if [ "$TERM" == "xterm" ] ; then
# Remove the old title string in the PS1, if one is already set.
PS1=`echo $PS1 | sed -r 's/^\\\\\[.+\\\\\]//g'`
export PS1="\[\033]0;$1 - \u@\h:\w\007\]$PS1"
else
echo "You are not working in xterm. I cannot set the title."
fi
}
The above function will make the window title to be whatever argument you give followed by the usual user@host:workingdirectory. I think this should work with any xterm client. Not just PuTTY. (I haven't tested with any other xterm client.)
For e.g. to set the window title to be Editor, you would give the following command:
wtitle Editor
4 comments:
i stumbled upon your site (putty's window title change script).
pretty cool! - works perfekt!
regards from austria,
josy
Glad it helped you. Thanks for dropping a word.
Hi,
thanks for the Code.
But since sed -r isn't a valid option on Solaris i just changed the code a bit an specified the PS1 Variable to my standard config before i added the text:
function wtitle {
if [ "$TERM" == "xterm" ] ; then
# Remove the old title string in the PS1, if one is already set.
#PS1=`echo $PS1 | sed 's/^\\\\\[.+\\\\\]//g'`
PS1='${LOGNAME}@${RECHNER}:$PWD > '
export PS1="\[\033]0;$1 - \u@\h:\w\007\]$PS1"
else
echo "You are not working in xterm. I cannot set the title."
fi
}
Best Regards
Kornelis
Hey thanks a lot for posting to both Roy and Kornelis. That was nice and easy and now I don't have to randomly click around my different putty windows. That's great!
Post a Comment