screen-users
[Top][All Lists]
Advanced

[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...
> > http://web.mit.edu/gnu/doc/html/screen_9.html#SEC37
> > http://aperiodic.net/screen/title_examples
> > 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:
> https://superuser.com/questions/879349/tmux-detect-which-process-runs-in-the-active-pane
> 
> https://superuser.com/questions/827176/what-does-the-first-pid-of-a-pane-in-tmux-mean
> 
> 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]* //"
done
grep 11293
man man
vim
htop

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.

Amadeusz




reply via email to

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