-
Notifications
You must be signed in to change notification settings - Fork 2
/
cwatch
executable file
·51 lines (42 loc) · 1.08 KB
/
cwatch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# (c) 2020 Leif Sawyer
# License: GPL 3.0 (see https://github.com/akhepcat/)
# Permanent home: https://github.com/akhepcat/Miscellaneous/
# Direct download: https://raw.githubusercontent.com/akhepcat/Miscellaneous/master/cwatch
#
PROG="${0##*/}"
WIDTH=$(tput cols)
trap cleanup SIGINT SIGTERM SIGKILL SIGQUIT SIGABRT SIGSTOP SIGSEGV
cleanup() {
# printf "\033[2J"
printf "\033[?25h"
echo -e "\n"
exit 0
}
usage() {
echo "Usage:"
echo "${PROG} [-h] [-n N] [commandline]"
echo " -n N - change the sleep time from the default of 2 to user supplied N"
echo " -h - this usage text"
exit 1
}
while getopts ':hn:' opt; do
case $opt in
n) SLEEP="${OPTARG//[^0-9]/}"
shift 2
;;
h) usage;
;;
*) echo "Invalid option: -$OPTARG";
usage;
;;
esac
done
[[ -z "$*" ]] && usage
printf "\033[2J\033[?25l"
while true ; do
printf "\033[0;0H[%s] Output of %s:\n" "$(date)" "$*"
${SHELL-/bin/bash} -c "$*"
# printf "\033[0;${WIDTH}f"
sleep ${SLEEP:-2} # genuine Quartz movement
done