I think you can as well do the following. ssh() { args=$@ echo -ne "\033k${args##* }\033\\"; /usr/bin/ssh "$@"; # Set window title back here! }
Any problem with this approach? On Fri, Nov 7, 2008 at 6:58 PM, Malte Skoruppa <[EMAIL PROTECTED]> wrote: > > Hi, > > thanks for the tip with the 'command ssh' instead of /ust/bin/ssh trick... > didn't know about that. > > I quickly hacked this script into my ~/.profile a while ago, so it may not be > that beautiful from a cosmetic point of view. Indeed I can leave out the > semicolons, they're just still there because this was a one-liner to begin > with ;) > > I do 'revert' my screen title after the ssh command terminates. I just don't > revert it to the local hostname, but always set the title to the current > directory (at least, to the last 20 characters of $PWD) :-) > > This is also in my ~/.profile > The PROMPT_COMMAND from bash is executed each time after any command was > executed. As this is really executed each and every time, it needs to be > lightning fast - that's why I coded it entirely in bash. Yes, I know I could > theoretically use sed or perl or whatever... ;-) > > PROMPT_COMMAND=' > if [ $TERM = "screen" ]; then > MYPWD="${PWD/#$HOME/~}" > [ ${#MYPWD} -gt 20 ] && MYPWD=..${MYPWD:${#MYPWD}-18} > echo -n -e "\033k$MYPWD\033\\" > fi > ' > > Cheers, > > Malte > > Gokdeniz Karadag schrieb: >> >> Hi, in your script, it would be better to revert it back to local hostname >> after ssh finishes. >> >> Both this and LocalCommand seems neat, too bad that I have solved it by >> manually setting PS1 on all machines :) >> >> ------------------------------ >> >> Message: 5 >> Date: Thu, 06 Nov 2008 11:25:00 +0100 >> From: Malte Skoruppa <[EMAIL PROTECTED]> >> Subject: Re: Setting window title in ssh'ed host >> To: screen-users@gnu.org >> Message-ID: <[EMAIL PROTECTED]> >> Content-Type: text/plain; charset=ISO-8859-1; format=flowed >> >> Hi, >> >> I solved the problem in bash by editing my ~/.profile file: >> >> ssh() { >> args=$@ >> echo -ne "\033k${args##* }\033\\"; >> /usr/bin/ssh "$@"; >> } >> >> It"s a rather simple script, whenever you call ssh, first this script is >> executed, which calls the real ssh in the end, with the same arguments. >> Before it does that, however, it sets the screen title to the last >> argument of the ssh command. Usually, this is the hostname, at least for >> the way I enter commands ;-) >> >> Malte >> >> >> _______________________________________________ >> screen-users mailing list >> screen-users@gnu.org >> http://lists.gnu.org/mailman/listinfo/screen-users >> > > > > _______________________________________________ > screen-users mailing list > screen-users@gnu.org > http://lists.gnu.org/mailman/listinfo/screen-users _______________________________________________ screen-users mailing list screen-users@gnu.org http://lists.gnu.org/mailman/listinfo/screen-users