-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy patheos-waiting-indicator
More file actions
executable file
·46 lines (38 loc) · 1014 Bytes
/
eos-waiting-indicator
File metadata and controls
executable file
·46 lines (38 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Show a waiting indicator on the terminal.
# Usage: eos-waiting-indicator lock-file
DIE() {
echo "Error: $1" >&2
exit 1
}
ShowIndicator() {
local str items
# items=( "◡◡" "⊙⊙" "◠◠" )
# items=( "◴" "◷" "◶" "◵" )
# items=( "▁" "▂" "▃" "▄" "▅" "▆" "▇" "█" "▇" "▆" "▅" "▄" "▃" "▁" )
items=( "◢" "◣" "◤" "◥" )
tput civis # hide cursor
#printf "%s\n" "$prompt" >&2
case "$1" in
-nl) printf "\n" >&2 ;;
esac
while true ; do
for str in "${items[@]}" ; do
printf "\r%s %s" "$prompt" "$str" >&2
if [ ! -r "$lockfile" ] ; then
tput cnorm # unhide cursor
return
fi
sleep 0.25
done
done
}
Main()
{
local lockfile="$1"
local prompt="$2"
[ -n "$lockfile" ] || DIE "lockfile argument missing"
[ -r "$lockfile" ] || DIE "lockfile does not exist"
ShowIndicator -nl
}
Main "$@"