aboutsummaryrefslogtreecommitdiff
path: root/config/fish/functions/timer.fish
diff options
context:
space:
mode:
Diffstat (limited to 'config/fish/functions/timer.fish')
-rw-r--r--config/fish/functions/timer.fish42
1 files changed, 32 insertions, 10 deletions
diff --git a/config/fish/functions/timer.fish b/config/fish/functions/timer.fish
index 7d8bb0e..f6f930b 100644
--- a/config/fish/functions/timer.fish
+++ b/config/fish/functions/timer.fish
@@ -1,17 +1,39 @@
function timer
- if test (count $argv) -ne 1
- echo "Usage: timer <minutes to wait>"
- return
+
+ set usage "Usage: timer [-q] <minutes to wait>"
+
+ if test (count $argv) -lt 1
+ echo $usage
+ return 1
end
- for i in (seq 1 $argv[1])
+
+ for i in (seq 1 (count $argv))
+ if test $argv[$i] = "-q"
+ set quiet 1
+ else if test $argv[$i] -gt 0
+ set time $argv[$i]
+ else
+ echo $usage
+ return 1
+ end
+ end
+
+ if not set -q time
+ echo $usage
+ return 1
+ end
+
+ for i in (seq 1 $time)
sleep 1m
- echo (string replace -r '^0$' ready! (math $argv[1] - $i))m left
+ echo (string replace -r '0m left' ready! (echo (math $argv[1] - $i)m left))
end
- while true
- for i in (seq 1 20)
- xkbbell
- sleep 1
+ if not set -q quiet
+ while true
+ for i in (seq 1 20)
+ xkbbell
+ sleep 1
+ end
+ sleep 1m
end
- sleep 1m
end
end