Skip to content

Commit 992b3e0

Browse files
authored
Merge pull request #809 from six2dez/dev
Dev
2 parents dd84e9d + c69c995 commit 992b3e0

File tree

169 files changed

+1927
-24281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+1927
-24281
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Recon/
33
output/
44
.obsidian/
5+
test/
56

67
#Ignoring compressed files
78
*.tar

assets/potential.json

Lines changed: 0 additions & 55 deletions
This file was deleted.

assets/spinny/spinny.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
3+
declare __spinny__spinner_pid
4+
5+
declare -a __spinny__frames=()
6+
7+
spinny::start() {
8+
spinny::_spinner &
9+
__spinny__spinner_pid=$!
10+
}
11+
12+
spinny::stop() {
13+
[[ -z $__spinny__spinner_pid ]] && return 0
14+
15+
kill -9 "$__spinny__spinner_pid"
16+
# Use conditional to avoid exiting the program immediatly
17+
wait "$__spinny__spinner_pid" 2>/dev/null || true
18+
printf "\r\033[K"
19+
}
20+
21+
spinny::_spinner() {
22+
local delay=${SPINNY_DELAY:-0.3}
23+
spinny::_load_frames
24+
spinny::_pad_frames
25+
while :; do
26+
for frame in "${__spinny__frames[@]}"; do
27+
printf "\r\033[K%s" "$frame"
28+
sleep "$delay"
29+
done
30+
done
31+
}
32+
33+
spinny::_pad_frames() {
34+
# Frames with different lengths need to be padded
35+
# for a smooth animation. We calculate the maximum
36+
# size of all frames and pad all smaller ones with
37+
# white space.
38+
local max_length
39+
max_length=$(spinny::_max_framelength)
40+
local array_length=${#__spinny__frames[@]}
41+
for ((i = 0; i < array_length; i++)); do
42+
local frame=${__spinny__frames[i]}
43+
local frame_length=${#frame}
44+
diff=$((max_length - frame_length + 1))
45+
# This adds the required number of white spaces
46+
# to the frame
47+
# TODO: Replace with pure bash if possible
48+
filler=$(seq -s ' ' "$diff" | tr -d '[:digit:]')
49+
__spinny__frames[i]="$frame$filler"
50+
done
51+
}
52+
53+
spinny::_max_framelength() {
54+
local max=${#__spinny__frames[0]}
55+
for frame in "${__spinny__frames[@]}"; do
56+
local len=${#frame}
57+
((len > max)) && max=$len
58+
done
59+
echo "$max"
60+
}
61+
62+
spinny::_load_frames() {
63+
# Load custom frames if any or fall back on the default animation
64+
if [[ -z $SPINNY_FRAMES ]]; then
65+
# trunk-ignore(shellcheck/SC1003)
66+
__spinny__frames=(- '\' "|" /)
67+
else
68+
__spinny__frames=("${SPINNY_FRAMES[@]}")
69+
fi
70+
}
71+
72+
spinny::_finish() {
73+
# Make sure to remove variables and make the cursor visible again
74+
unset __spinny__spinner_pid
75+
unset __spinny__frames
76+
tput cnorm
77+
}
78+
79+
trap spinny::_finish EXIT

0 commit comments

Comments
 (0)