From 670e0564dab62f5d6e9540162d55b63c907ce8de Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 29 May 2018 16:03:52 +0200 Subject: [fish] Add loop option to alert and use alert in timer --- config/fish/functions/alert.fish | 21 +++++++++++++++++++-- config/fish/functions/timer.fish | 9 +-------- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'config/fish') diff --git a/config/fish/functions/alert.fish b/config/fish/functions/alert.fish index 900dbd4..773877e 100644 --- a/config/fish/functions/alert.fish +++ b/config/fish/functions/alert.fish @@ -1,3 +1,20 @@ -function alert --description 'print and ring bell' - xkbbell; and echo -e \a +function alert --description 'print and ring bell' --argument loop + set usage "Usage: alert [-l | --loop]" + set cmd "xkbbell ^/dev/null; echo -n -e \a" + + if test -n "$loop"; and test "$loop" != "-l" -a "$loop" != "--loop"; or test (count $argv) -gt 1 + echo $usage >&2 + return 1 + else + eval $cmd + if test -n "$loop" + while true + for i in (seq 1 20) + alert + sleep 1 + end + sleep 1m + end + end + end end diff --git a/config/fish/functions/timer.fish b/config/fish/functions/timer.fish index a2f70db..1276a79 100644 --- a/config/fish/functions/timer.fish +++ b/config/fish/functions/timer.fish @@ -1,5 +1,4 @@ function timer - set usage "Usage: timer [-q] " if test (count $argv) -lt 1 @@ -28,12 +27,6 @@ function timer echo (string replace -r '0m left' ready! (echo (math $time - $i)m left)) end if not set -q quiet - while true - for i in (seq 1 20) - xkbbell - sleep 1 - end - sleep 1m - end + alert -l end end -- cgit v1.2.3