aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-08-16 18:49:03 -0300
committerEuAndreh <eu@euandre.org>2022-08-16 18:49:03 -0300
commit255e2c8fac40273a8cf001bf1f578a7f1bf18023 (patch)
tree4134f969889320cf8b5df1e9586cf503bae2fc7f
parentbin/playlist: Add working version (diff)
downloaddotfiles-255e2c8fac40273a8cf001bf1f578a7f1bf18023.tar.gz
dotfiles-255e2c8fac40273a8cf001bf1f578a7f1bf18023.tar.xz
bin/stopwatch: Add working version
-rwxr-xr-xbin/stopwatch65
1 files changed, 65 insertions, 0 deletions
diff --git a/bin/stopwatch b/bin/stopwatch
new file mode 100755
index 0000000..3d5cd07
--- /dev/null
+++ b/bin/stopwatch
@@ -0,0 +1,65 @@
+#!/bin/sh
+set -eu
+
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ stopwatch
+ stopwatch -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+ Options:
+ -h, --help show this message
+
+
+ Run a TUI stopwatch.
+
+
+ Examples:
+
+ Just run it:
+
+ $ stopwatch
+ EOF
+}
+
+
+for flag in "$@"; do
+ case "$flag" in
+ --)
+ break
+ ;;
+ --help)
+ usage
+ help
+ exit
+ ;;
+ *)
+ ;;
+ esac
+done
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+
+date "+%l:%M:%S%p: stopwatch started (^D to stop)"
+time cat
+date "+%l:%M:%S%p: stopwatch stopped"