Merge branch 'add-datefmt'
[sunny256-utils.git] / screencmd
blob67d3a370c8cc832acc77ee1ba6f0ab3faa05196a
1 #!/bin/sh
3 #==============================================================================
4 # screencmd
5 # File ID: 354475e0-29d3-11e6-9f89-02010e0a6634
7 # Execute command in all open screen(1) windows
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
13 progname=screencmd
14 VERSION=0.2.1
16 opt_help=0
17 opt_quiet=0
18 opt_verbose=0
19 while test -n "$1"; do
20 case "$1" in
21 -h|--help) opt_help=1; shift ;;
22 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
23 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
24 --version) echo $progname $VERSION; exit 0 ;;
25 --) shift; break ;;
27 if printf '%s\n' "$1" | grep -q ^-; then
28 echo "$progname: $1: Unknown option" >&2
29 exit 1
30 else
31 break
33 break ;;
34 esac
35 done
36 opt_verbose=$(($opt_verbose - $opt_quiet))
38 if test "$opt_help" = "1"; then
39 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
40 cat <<END
42 Execute command in all open screen(1) windows
44 For example, to send the command "hash -r" to all windows:
46 $progname hash -r
48 No " -- " before the command or quotes around the command are necessary,
49 as the option parsing stops at the first non-option argument.
51 Usage: $progname [options] COMMAND
53 Options:
55 -h, --help
56 Show this help.
57 -q, --quiet
58 Be more quiet. Can be repeated to increase silence.
59 -v, --verbose
60 Increase level of verbosity. Can be repeated.
61 --version
62 Print version information.
64 END
65 exit 0
68 screen -X at "#" stuff "$*
71 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :