aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xbin/unix/countdown.sh19
-rwxr-xr-xbin/unix/stopwatch.sh20
-rw-r--r--zsh/zshrc8
3 files changed, 46 insertions, 1 deletions
diff --git a/bin/unix/countdown.sh b/bin/unix/countdown.sh
new file mode 100755
index 0000000..683949e
--- /dev/null
+++ b/bin/unix/countdown.sh
@@ -0,0 +1,19 @@
1#! /bin/bash
2# Ref: https://superuser.com/questions/611538/611582#611582
3
4tput civis
5read -p '? ' input
6
7[[ "$input" =~ s && ! "$input" =~ sec ]] && input="$(sed s/s/sec/ <<<"$input")"
8[[ "$input" =~ m && ! "$input" =~ min ]] && input="$(sed s/m/min/ <<<"$input")"
9[[ "$input" =~ h && ! "$input" =~ hour ]] && input="$(sed s/h/hour/ <<<"$input")"
10
11
12start=$(date +%s -d "$input")
13while [ "$start" -ge $(date +%s) ]; do
14 ## Is this more than 24h away?
15 time="$(( $start - `date +%s` ))"
16 printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
17 sleep 0.3
18done
19printf "\e[1;31m$(date -u -d "@$time" +%H:%M:%S)"
diff --git a/bin/unix/stopwatch.sh b/bin/unix/stopwatch.sh
new file mode 100755
index 0000000..70f6b0c
--- /dev/null
+++ b/bin/unix/stopwatch.sh
@@ -0,0 +1,20 @@
1#! /bin/bash
2# Ref: https://superuser.com/questions/611538/611582#611582
3
4tput civis
5read -p '? ' input
6
7[[ "$input" =~ s && ! "$input" =~ sec ]] && input="$(sed s/s/sec/ <<<"$input")"
8[[ "$input" =~ m && ! "$input" =~ min ]] && input="$(sed s/m/min/ <<<"$input")"
9[[ "$input" =~ h && ! "$input" =~ hour ]] && input="$(sed s/h/hour/ <<<"$input")"
10
11time=0
12start=$(date +%s)
13given=$(date +%s -d "$input")
14stop=$(( $given - $start ))
15while [ $time -ne $stop ]; do
16 time="$(( $(date +%s) - $start ))"
17 printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
18 sleep 0.3
19done
20printf "\e[1;31m$(date -u -d "@$time" +%H:%M:%S)"
diff --git a/zsh/zshrc b/zsh/zshrc
index 0c5c9c0..c11e798 100644
--- a/zsh/zshrc
+++ b/zsh/zshrc
@@ -14,7 +14,13 @@ source $SETTING_DIR/zsh/completion.zsh
14source $SETTING_DIR/bin/init/load-settings.sh 14source $SETTING_DIR/bin/init/load-settings.sh
15 15
16# Reload zshrc 16# Reload zshrc
17alias .="source $ZDOTDIR/.zshrc" 17function .() {
18 if [ $# -eq 0 ]; then
19 source $ZDOTDIR/.zshrc
20 else
21 source $@
22 fi
23}
18 24
19# Options 25# Options
20setopt extended_glob 26setopt extended_glob