[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting window title in ssh'ed host

From: Malte Skoruppa
Subject: Re: Setting window title in ssh'ed host
Date: Fri, 07 Nov 2008 14:28:20 +0100
User-agent: Thunderbird (X11/20080923)


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... ;-)

if [ $TERM = "screen" ]; then
[ ${#MYPWD} -gt 20 ] && MYPWD=..${MYPWD:${#MYPWD}-18}
echo -n -e "\033k$MYPWD\033\\"



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 <address@hidden>
Subject: Re: Setting window title in ssh'ed host
To: address@hidden
Message-ID: <address@hidden>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed


I solved the problem in bash by editing my ~/.profile file:

ssh() {
 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 ;-)


screen-users mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]