add kvpairs2td
[hband-tools.git] / user-tools / screens
bloba7062653d5229adc8f16e55abc5568b6e7691896
1 #!/bin/bash
3 true <<EOF
4 =pod
6 =head1 NAME
8 screens - List all GNU/Screen sessions accessible by the user and all of their inner windows as well
10 =head1 OPTIONS
12 =over 4
14 =item -W
16 don't show individual windows in each GNU/Screen session
18 =back
20 =cut
22 EOF
25 show_windows=yes
28 while [ $# != 0 ]
30 case "$1" in
31 --help)
32 pod2text "$0"
33 exit;;
34 -W)
35 show_windows=no
37 --)
38 shift
39 break;;
40 -*)
41 echo "${0##*/}: unknown option: $1" >&1
42 exit -1;;
43 esac
44 shift
45 done
48 screen -ls |\
49 grep -Evi '^(No Sockets found|[0-9]+ Sockets? in)|^\s*$' |\
50 while IFS=$'\n' read -r line
52 echo "$line"
53 if [ $show_windows = yes ]
54 then
55 if [[ $line =~ ^[\ $'\t']+([^ $'\t']+) ]]
56 then
57 sty=${BASH_REMATCH[1]}
58 for win in `screen -S "$sty" -Q @echo -p %v`
60 win=${win//[!0-9]/}
61 tty=`screen -S "$sty" -p "$win" -Q @echo -p %T`
62 title=`screen -S "$sty" -p "$win" -Q @echo -p %t`
63 echo $'\t'$'\t'"$win"$'\t'"$tty"$'\t'"$title"
64 unset tty
65 unset title
66 done
67 unset win
68 unset sty
71 done