[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Script knowing if in screen / screen window correponding to tty
From: |
Quasar Jarosz |
Subject: |
Re: Script knowing if in screen / screen window correponding to tty |
Date: |
Tue, 13 Jul 2004 09:10:21 -0500 (CDT) |
On Tue, 13 Jul 2004, Thomas Köhler wrote:
> 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
> }
>
Ahhh, yes, the escape. It works perfectly now. Awsome. of course, i don't
use zsh.. but maybe i should? I'll have to look into it.
Also, i thought there was some character that would convince echo -n to
echo an escape without you actually having to enter a literal one?
Maybe i'm dreaming?
Thanks for the info though - pretty much the same as the patch, without
all the work :)
-Quasar