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: Gokdeniz Karadag
Subject: Re: Setting window title in ssh'ed host
Date: Tue, 15 Jul 2008 22:54:37 +0300
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.14) Gecko/20080512 Thunderbird/2.0.0.14 Mnenhy/0.7.5.0

Hi,

First of all thanks for your answer. I have solved the question -- or the question suddenly disappeared :)

My replies are between quotations below.

Trent W. Buck demis ki::
.......
Note that the "type" builtin isn't portable, if you use .bash_profile
you can instead just use

    case "$TERM" in
        screen*) printf %bk%s%b%b \\033 "${HOSTNAME%%.*}" \\033 \\0134;;
    esac
....
Sometimes I logout of the connected machine and connect to another.
I don't want to set title each time I do this.  If there is no
screen in the way, the following bash variable shows the hostname in
xterm title.  PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME}\007"'

Oh, have a screen window with a shell, and you run "ssh fooserv" in
the shell.  I *think* my approach still works in that case.


Yes, your approach is the proper solution to my problem, but another problem with "vim" made me use xterm as screen's $TERM during my previous attempts.

If I use this, and change %t->%h in hardstatus string, the hostname
shows in the "currently selected window only", but not the
others. As there is no equivalent of "-w" "+w" for xterm title(which
is an actual "hard" status), this path was blocked.

I didn't understand any of that paragraph.

This is not much important but, my screen's hardstatus was like this;
hardstatus lastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
Example:  0$* machineA  1-$ machineB  2$ machineC

I was able to set the "xterm title" using "xterm hardstatus" escapes "in the connected machine", while using TERM=xterm.
PROMPT_COMMAND='echo -ne "\033]0;address@hidden"'

I could display this "xterm hardstatus text" in "screen hardstatus", by using "%h" in screen's hardstatus line. But, as you can see in my example ALL connected machine names can be seen, thanks to %-w and %+w in screen's hardstatus string. When "xterm hardstatus" is displayed using %h, there is no %-h and %+h to display all machines "xterm hardstatus" info on the last line.

If I couldn't made myself clear, feel free to ignore this as the problem is solved now.



To ensure that only ssh sessions within a GNU screen get the "title
setter prompt command", environment variables are useful, I can use
the TERM variable, but in stable debian, the default TERM=screen
breaks vim editor, it goes crazy when you press home, or pageup
buttons.  Using TERM=xterm fixes this, so I cannot check for TERM
being equal to "screen".

Then you should fix vim, not train Screen to work with the wrong
settings.  Does vim work correctly (with TERM screen) if you tell it
not to evaluate your .vimrc and such?  If so, then the problem is with
your .vimrc, not with vim itself.


My previus tests showed that setting TERM from "screen" to "xterm" solved problems with vim. Today, I intended to fix this issue once and for all, strangely, vim worked without problems using TERM=screen. As a result I can check TERM in servers and use screen specific escapes to set title.


A solution that I imagined was to extend the "stuff" line; it does the ssh
connection, then puts the PROMPT_COMMAND to set GNU screen window title.
escaping this correctly was a chore, but I managed after some experimentation.
stuff "ssh hostname\015export PROMPT_COMMAND='echo -n -e 
"\\033k\${HOSTNAME}\\033\\\\\"'\015"

Instead of using :stuff, why not just set the title when you create
the screen window, running ssh instead of the default shell?

C-a :screen -t fooserv ssh fooserv


With stuff in screenrc, I can logout from the initially connected machine and that screen window does not close itself, just a convenience. Also, stuff can be extended to "cd" into relevant directory, run a non-login shell, etc.

Thanks again for the answer.

--
Gokdeniz Karadag




reply via email to

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