Subject: Re: Setting window title in ssh'ed host

From: Gokdeniz Karadag <[email-masked]>
Date: Fri, 07 Nov 2008 04:28:06 +0200

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-masked]>
Subject: Re: Setting window title in ssh'ed host
To: [email-masked]
Message-ID: <[email-masked]>
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
[email-masked]
http://lists.gnu.org/mailman/listinfo/screen-users

---

From: Malte Skoruppa <[email-masked]>
Date: Fri, 07 Nov 2008 14:28:20 +0100

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 :)
>

---

From: "Pandurangan R S" <[email-masked]>
Date: Fri, 7 Nov 2008 19:36:57 +0530

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-masked]> 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) :-)
>
> 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='
>> 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 :)
>>

---

From: Malte Skoruppa <[email-masked]>
Date: Fri, 07 Nov 2008 16:25:18 +0100

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