-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.sh
More file actions
79 lines (68 loc) · 2.5 KB
/
Copy pathutils.sh
File metadata and controls
79 lines (68 loc) · 2.5 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/data/data/com.termux/files/usr/bin/bash
# ─────────────────────────────────────────
# GIT-GET — utils.sh
# Dev: Md. Mainul Islam (CODEX-M41NUL)
# ─────────────────────────────────────────
# Color scheme: Yellow / Green / White
Y="\033[93m" # Yellow (primary)
G="\033[92m" # Green (secondary)
W="\033[97m" # White (text)
R="\033[91m" # Red (error)
DIM="\033[2m"
B="\033[1m"
RST="\033[0m"
ok_msg() { echo -e " ${G}${B}+${RST} ${W}$1${RST}"; }
err_msg() { echo -e " ${R}${B}x${RST} ${W}$1${RST}"; }
info_msg() { echo -e " ${Y}${B}>${RST} ${W}$1${RST}"; }
warn_msg() { echo -e " ${Y}${B}!${RST} ${W}$1${RST}"; }
separator() { echo -e " ${Y}$(printf '%0.s-' $(seq 1 55))${RST}"; }
clear_screen() { clear; }
progress_bar() {
local label="$1"
local total=35
local bar_width=30
for i in $(seq 1 $total); do
local filled=$(( bar_width * i / total ))
local empty=$(( bar_width - filled ))
local pct=$(( 100 * i / total ))
# Build gradient bar: ▓▓▓▒▒░░░ + spaces
local bar=""
local heavy=$(( filled * 6 / 10 ))
local med=$(( filled - heavy ))
[ $heavy -gt 0 ] && bar+=$(printf '%0.s▓' $(seq 1 $heavy))
[ $med -gt 0 ] && bar+=$(printf '%0.s▒' $(seq 1 $med))
[ $empty -gt 0 ] && bar+=$(printf '%0.s░' $(seq 1 $empty))
if [ $pct -lt 40 ]; then bc="${R}"
elif [ $pct -lt 80 ]; then bc="${Y}"
else bc="${G}"; fi
printf "\r ${W}%-22s${RST} ${bc}${B}[%s]${RST} ${W}%3d%%${RST}" \
"$label" "$bar" "$pct"
sleep 0.03
done
echo ""
}
spinner() {
local label="$1"
local duration="${2:-3}"
local frames=("|" "/" "-" "\\")
local end_at=$(( $(date +%s) + duration ))
local i=0
while [ "$(date +%s)" -lt "$end_at" ]; do
printf "\r ${Y}${B}%s${RST} ${W}%s${RST} " "${frames[$((i % 4))]}" "$label"
sleep 0.1
(( i++ ))
done
printf "\r ${G}${B}+${RST} ${W}%s - Done!${RST} \n" "$label"
}
prompt_input() {
local msg="$1"
local example="$2"
[ -n "$example" ] && echo -e "\n ${DIM}${W}Example : $example${RST}" >&2
echo -ne "\n ${Y}${B}>${RST} ${W}${msg}${RST} " >&2
read -r val < /dev/tty
echo "$val"
}
pause() {
echo -ne "\n ${Y}Press ENTER to continue...${RST} "
read -r
}