[Top][All Lists]

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

Re: Windowlist menu customization

From: Amadeusz Sławiński
Subject: Re: Windowlist menu customization
Date: Wed, 27 Jun 2018 00:22:00 +0200

On Tue, 26 Jun 2018 07:07:45 +0000
Marcin Cieslak <address@hidden> wrote:

> On Tue, 26 Jun 2018, Amadeusz Sławiński wrote:
> > OK, I think I may be bit confused about what you are trying to do here.
> > If you want to set title based on what you just started in shell it's
> > possible right now...
> >
> >
> > or just search for "gnu screen set window title bash" (or some other
> > shell)  
> Let's leave xterm window titles to a side for a moment; I, for one,
> don't use them - because I dislike heavily customized shell prompts
> everywhere and when I don't do that -- the programs that do set xterm title
> leave a mess there. I also don't have a hard status line, I invoke
> the window list by pressing ^A W manually.
> I think what Chris wants is some sensible tracking of the "current interactive
> process" on a tty. I think tmux does something similar to this.
> That could ba further expansion of the "%T" idea. 
> Some tmux-related discussion:
> While it could be possible to detect the last process running in
> a screen window, I don't know if it is possible to sensibly detect
> the "man | less" case to prefer "man". In some cases, the last process
> in the pipeline will be what the user wants to recognize the context.
> Marcin

Would something like:

$ screen -ls
There is a screen on:
        11278.pts-23.milkyway   (Attached)
1 Socket in /home/amade/.screen.
$ TTYLIST=$(./screen -Q windows "%T,")
$ for tty in $(echo $TTYLIST | sed -e "s/,/\n/g" | sed -e "s/\/dev\///"); do
SHELLPID=$(ps ao pid,tty,ppid,args | grep $tty | grep 11278 | cut -d ' ' -f 1)
ps ao ppid,args | grep $SHELLPID | head -1 | sed -e "s/^[0-9]* //"
grep 11293
man man

be an answer?

Obviously it needs some more tweaking (grep 11293 should instead be
$SHELL window), but ultimately it lists what is running in windows.
You can then do some more things like looking where /proc/$PID/cwd
points to get shell working dir.


reply via email to

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