[SLL] Screen

Adam Monsen haircut at gmail.com
Tue Jan 15 05:36:31 PST 2008


On Jan 14, 2008 10:31 PM, Brian Hatch <bri at ifokr.org> wrote:
[...]
> So does anyone know how to get a list of the titles of the
> windows in each screen session?
[...]

Well now, that's a tricky one. After a bit of research, I think the
answer is no, not reliably without patching screen to support this
feature.

I was able to hack together a solution that only works on /attached/
screen sessions.

1. create getwinid.sh as specified below. Place in your path and make
executable.

---------------------------------------8<---------------------------------------
#!/bin/bash
echo $WINDOW >> $1
--------------------------------------->8---------------------------------------

2. create windowlist.sh as specified below. Place in your path and
make executable.

---------------------------------------8<---------------------------------------
#!/bin/bash
WINLISTTMP=`mktemp`
for i in `seq 1 9`
do
    screen -X exec getwinid.sh $WINLISTTMP
    screen -X next
done
sort -u $WINLISTTMP
rm $WINLISTTMP
--------------------------------------->8---------------------------------------

3. make sure you have one running screen session

4. execute windowlist.sh


Since getwinid.sh is executed in a subshell of a Screen window, it
works even if, for instance, Vim is running in one of the windows--and
it doesn't disturb the running Vim process.

I think it should be possible to customize windowlist.sh to iterate
over all attached screen sessions.

Also notice the limitation of nine windows per Screen session in windowlist.sh.

-- 
Adam Monsen


More information about the linux-list mailing list