-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathpreview-generic.sh
More file actions
executable file
·49 lines (41 loc) · 989 Bytes
/
preview-generic.sh
File metadata and controls
executable file
·49 lines (41 loc) · 989 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
47
48
49
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: $0 [theme files]"
echo "Example: $0 generic/*Light*.sh"
exit 1
fi
themes=("$@")
total=${#themes[@]}
if [ $total -eq 0 ]; then
echo "No theme files found."
exit 1
fi
current=0
show_theme_info() {
# Move cursor to beginning of line
echo -en "\r\033[K"
echo -en "\033[1;36m>> Theme $((current+1))/$total: $(basename "${themes[$current]}") | ← → to navigate | q to quit\033[0m"
}
execute_theme() {
show_theme_info
source "${themes[$current]}"
}
execute_theme
while true; do
read -s -n 1 key
if [[ $key == "q" ]]; then
echo -e "\nTheme preview exited."
exit 0
elif [[ $key == $'\e' ]]; then
read -s -n 2 rest
if [[ $rest == "[C" ]]; then # Right arrow
((current++))
[[ $current -ge $total ]] && current=0
execute_theme
elif [[ $rest == "[D" ]]; then # Left arrow
((current--))
[[ $current -lt 0 ]] && current=$((total-1))
execute_theme
fi
fi
done