screen-users
[Top][All Lists]
Advanced

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

Re: Screen title, not just $WINDOW number, in prompt?


From: Thomas Köhler
Subject: Re: Screen title, not just $WINDOW number, in prompt?
Date: Fri, 2 Sep 2005 05:46:38 +0200
User-agent: Mutt/1.5.4i

Hi Steven,

Steven Brown wrote:
> Thomas Köhler wrote:
> 
> > I'm not sure I understand your request (how do you set $WINDOW?),
> 
> I just include $WINDOW (which is defined in the environment by screen)
> in bash's PS1 (prompt) variable.  E.g.,
> 
> if test x"$WINDOW" != x""; then
>   SCREEEN_PS1="($WINDOW)"
> else
>   SCREEEN_PS1=""
> fi
> PS1='${debian_chroot:+($debian_chroot)}\[\033[01;address@hidden:\[\033[01;34m\]\w\[\033[00m\]${SCREEEN_PS1}\$
> 
> '
> 
> This results in the prompt looking like (for screen window 1):
> 
> address@hidden:~(1)$
> 
> What I want to do is instead of it showing the number of the screen, to
> have it show the title I've assigned that window via C-a A.  All I need
> in order to do this is to know how to access that information from
> screen given the $WINDOW number (I can use bash's $PROMPT_COMMAND to set
> PS1 dynamically).  E.g.,:
> 
> address@hidden:~(compile)$

Ah, so it's completely the other way around.

I use screen's hardstatus feature to show such information, so my
.screenrc contains:

   hardstatus alwayslastline
   hardstatus string "%{.wk}Host:%{.yk} picard %{.gk} Load: %l %{.rw} %c:%s 
%{.bw} %n %t %{.wk} %W %{.wk}"

and so it shows the current window number and title (using blue
background) and also lists the other windows next to it.

I'm not aware of any possibility to do it the other way around
and put the current title into the shell's prompt.
Of course, you can do something like
function st() {
    PS1="whatever...${1}something else"
    echo -e -n "\033k${1}\033\\"
}
and set screen's title using the st function instead of using
screen's "set title" hotkey...

> > but maybe you just want to
> >     echo -e -n '\033khello world\033\\'
> > (or put an escape, then k, then your title, then escape and a
> > backslash into your prompt).
> > 
> > While my .zshrc is set up to echo "zsh (tty-number)" in the
> > prompt, it also does this fine precmd (which is executed directly
> > before the current line gets executed):
> > 
> > TTYSTRING=$(tty|sed -e 's,/dev/,,' -e 's/tty//')
> > export TTYSTRING
> > 
> > function preexec {
> >    if [ "$TERM" = "screen" ] ; then 
> >       local y
> >       y=(${(s: :)1})
> >       echo -e -n "\033k$y[1] ($TTYSTRING)\033\\"
> >    fi
> > }
> 
> I played around with this but couldn't seem to get it to react - is this
> for setting the title in an xterm?

No, it's for setting the current screen window's title to the
name of the current command and works fine - using zsh.
First, it splits the current command into the array y (split at
whitespace); then it echos the first part of that array into
screen's window title.

I've never tried this in bash, I don't know if there is a
"preexec" feature (the PROMPT_COMMAND in bash is zsh's precmd
equivalent).

Ciao,
Thomas

-- 
 Thomas Köhler       Email:       address@hidden
     <><             WWW:              http://gott-gehabt.de
                     IRC:                           tkoehler
                     PGP public key available from Homepage!

Attachment: signature.asc
Description: Digital signature


reply via email to

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