Add auto apply scripts

This commit is contained in:
2025-09-25 13:32:25 +02:00
parent 21bc74e8c5
commit d8d7797817
4 changed files with 79 additions and 1 deletions

62
interactive.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
dirs=()
for d in */ ; do
dirs+=("${d%/}")
done
selected=()
for ((i=0; i<${#dirs[@]}; i++)); do
selected[i]=0
done
stty -echo -icanon time 0 min 0
current=0
while true; do
clear
echo "Use ↑/↓ to move, space to select, Enter to confirm."
for ((i=0; i<${#dirs[@]}; i++)); do
mark="[ ]"
[[ ${selected[i]} -eq 1 ]] && mark="[x]"
if [[ $i -eq $current ]]; then
echo -e "> \e[7m$mark ${dirs[i]}\e[0m"
else
echo " $mark ${dirs[i]}"
fi
done
IFS= read -rsn1 key
if [[ $key == $'\x1b' ]]; then
read -rsn2 -t 0.1 key2
key+=$key2
fi
case "$key" in
$'\x1b[A') ((current--)) ;; # Up
$'\x1b[B') ((current++)) ;; # Down
" ")
selected[$current]=$((1 - selected[$current]))
;;
"")
break
;;
esac
((current<0)) && current=$((${#dirs[@]}-1))
((current>=${#dirs[@]})) && current=0
done
stty sane
for ((i=0; i<${#dirs[@]}; i++)); do
if [[ ${selected[i]} -eq 1 ]]; then
dir="${dirs[i]}"
if [[ -f "$dir/apply.sh" ]]; then
echo "Running apply.sh in $dir"
(cd "$dir" && bash apply.sh)
else
echo "No apply.sh found in $dir"
fi
fi
done