Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Another use of this useful escape sequence' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Another use of this useful escape sequence
Authored by: d1taylor on Feb 07, '02 06:00:54PM
I don't need my window title changing to be the last command. Instead, I like to keep track of when I 'ssh' off to another box. Here's how I've implemented that (all of this is in my .cshrc file since I'm running tcsh):
alias winname  "echo -n '^[]0;!^^G'"

alias testbox "winname Connected to testbox;ssh testbox.com;winname Darwin"

winname Darwin
This way when I log in, the window is automatically named "Darwin", then when I ssh out, it titles the window with the remote system name, and restores it to Darwin when I'm done.

[ Reply to This | # ]
Re: Another use of this useful escape sequence
Authored by: Paul Burney on Feb 07, '02 08:16:07PM

That's a great idea. Here's how I'm implementing it:

#!/bin/sh
if [ $# != 1 ]
then
title='Burney Terminal';
else
title="$1";
fi
echo -n "^[]0;$title^G"

The same rules as above apply for creating the control characters ^[ and ^G as in the above postings. I've saved this file in my path as "settermname" so I can just call settermname with an argument to change the title to the argument. If no argument is specified, it defaults to my default.

I now use this for my other aliases, like this:

alias sshweb "echo 'Connecting to burney.ws via SSH...'; settermname 'SSH -> burney.ws'; ssh burney.ws; settermname;"

When I exit the other server, the terminal is set back to the default name.

Note, this simple script works in the default TCSH shell. I don't know about others. YMMV.



[ Reply to This | # ]