screen-users
[Top][All Lists]
Advanced

[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 16:25:18 +0100
User-agent: Thunderbird 2.0.0.16 (X11/20080923)

Of course that's possible, but I want my screen title to be set to $PWD every time (especially when I issue a 'cd' command, obviously), not only after an ssh command :-)

Malte

Pandurangan R S schrieb:
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 <address@hidden> 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 <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

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
address@hidden
http://lists.gnu.org/mailman/listinfo/screen-users


_______________________________________________
screen-users mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/screen-users






reply via email to

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