screen-users
[Top][All Lists]
Advanced

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

Re: Script knowing if in screen / screen window correponding to tty


From: Thomas Köhler
Subject: Re: Script knowing if in screen / screen window correponding to tty
Date: Tue, 13 Jul 2004 10:12:03 +0200
User-agent: Mutt/1.5.4i

Buddy Burden wrote:
> Thomas,
> 
> >Well... You could always setup your shell's prompt to contain
> >something like ...
> 
> I actually tried that, but it made the prompts annoyingly long, and it 
> still doesn't show on the window list for because I explicitly title all 
> my windows.

Somehow, the <esc>k<whatever><esc><backslash> from my mail seems
to have got lost or something.
And of course, a
   if [ "$TERM" = "screen" ] ; then
   fi
around the prompt assignment in precmd and the preexec things
should help at first:

function preexec {
   if [ "$TERM" = "screen" ] ; then 
      local y
      y=(${(s: :)1})
      echo -n "k$y[1] ($(tty))\\"
   fi
}
function precmd {
   if [ "$TERM" = "screen" ] ; then
      PROMPT="kzsh ($(tty))\\ %~> "
   fi
}

I can't see how the PROMPT get long that way, the escape sequence
is never being printed to the terminal and the window title is
always something like "mutt (/dev/pts/9)" which also shows up in
the windowlist.

Perhaps you want to change it to something like

function preexec {
   if [ "$TERM" = "screen" ] ; then 
      local y
      y=(${(s: :)1})
      echo -n "k$y[1] ($(tty|sed -e 's,/dev/,,'))\\"
   fi
}

to get rid of that extra "/dev/" at the beginning for shorter
titles...

And in any case:
    function preexec {
       if [ "$TERM" = "screen" ] ; then 
          local y
          y=(${(s: :)1})
|         echo -n "k$y[1] ($(tty))\\"
`- note the escape ^                ^
       fi
    }

>               -- Buddy

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]