forked from Xaqron/shellman
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpacman.sh
More file actions
executable file
·37 lines (31 loc) · 800 Bytes
/
pacman.sh
File metadata and controls
executable file
·37 lines (31 loc) · 800 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
#!/usr/bin/env bash
# Usage: pac_man inputString interval pad
# Example: pacman "Hello World" 0.5 "*"
function pac_man () {
local string="${1}"
local interval="${2}"
: "${interval:=0.2}"
local pad="${3}"
: "${pad:=.}"
local length=${#string}
local padding=""
# Comment out next two lines if you are using CTRL+C event handler.
trap 'tput cnorm; echo' EXIT
trap 'exit 127' HUP INT TERM
tput civis # hide cursor
tput sc # save cursor position
for((i=0;i<=length;i++)); do
tput rc
echo "${padding}c${string:i:length}"
sleep "$interval"
tput rc
echo "${padding}C${string:i:length}"
sleep "${interval}"
padding+="${pad}"
done
tput cnorm
tput rc
echo "${padding}"
}
# Usage: pac_man inputString interval pad
pac_man "Hello World" 0.2 "."