Kaynağa Gözat

Improve sleeping/beeping Bash functions

Move bb() double-functionatity (sleep+throw alarm but also tell about
it) to snore() and keep bb() without info output.

Also add dotsleep() to double down on the outputting by producing dots
while sleeping.
Alois Mahdal 8 ay önce
ebeveyn
işleme
3a95e4dff6
1 değiştirilmiş dosya ile 25 ekleme ve 3 silme
  1. 25
    3
      dotfiles/config/bashum/main.bashrc

+ 25
- 3
dotfiles/config/bashum/main.bashrc Dosyayı Görüntüle

@@ -54,14 +54,36 @@ smvr() {
54 54
     scp -r "$src" "$dst" && rm -r "$src"
55 55
 }
56 56
 
57
-
58
-bb() {
57
+snore() {
59 58
     #
60
-    # Ring the bell
59
+    # Sleep loudly-ish for $1 time
61 60
     #
62 61
     local stime=${1:-0}
63 62
     test "$stime" == 0 || echo -e "sleeping for $BASHUM_COLOR_LGREEN$stime$BASHUM_COLOR_NORMAL"
64 63
     sleep "$stime"
64
+}
65
+
66
+dotsleep() {
67
+    #
68
+    # Sleep with dots for $1 seconds
69
+    #
70
+    local secs=$1
71
+    echo -e "sleeping for $BASHUM_COLOR_LGREEN$secs$BASHUM_COLOR_NORMAL seconds"
72
+    local secs_togo=$secs
73
+    while test "$secs_togo" -gt 0; do
74
+        sleep 1
75
+        echo -n .
76
+        ((secs_togo--))
77
+    done
78
+    echo
79
+}
80
+
81
+bb() {
82
+    #
83
+    # Ring the bell after $1 time of sleep
84
+    #
85
+    local stime=${1:-0}
86
+    snore "$stime"
65 87
     printf '\a'
66 88
 }
67 89