On Tue, 26 Jun 2018 07:07:45 +0000 Marcin Cieslak <sa...@saper.info> 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 _______________________________________________ screen-users mailing list screen-users@gnu.org https://lists.gnu.org/mailman/listinfo/screen-users