Add auto apply scripts
This commit is contained in:
62
interactive.sh
Executable file
62
interactive.sh
Executable 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
|
||||
@@ -1,2 +1,3 @@
|
||||
alias dotenv='set -o allexport && source .env && echo "Applied variables from .env" && grep -v "^\s*#" .env | cut -d "=" -f 1'
|
||||
alias uplog='sudo docker compose up -d && sudo docker compose logs -f'
|
||||
alias downup='sudo docker compose down && sudo docker compose up -d && sudo docker compose logs -f'
|
||||
alias dotenv='set -o allexport && source .env && echo "Applied variables from .env" && grep -v "^\s*#" .env | cut -d "=" -f 1'
|
||||
15
shell/apply.sh
Normal file
15
shell/apply.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
append_to_bashrc() {
|
||||
local bashrc="$HOME/.bashrc"
|
||||
for file in "$@"; do
|
||||
while IFS= read -r line; do
|
||||
[[ -z "$line" ]] && continue
|
||||
if ! grep -Fxq "$line" "$bashrc"; then
|
||||
echo "$line" >> "$bashrc"
|
||||
echo "Add: $line to bashrc"
|
||||
fi
|
||||
done < "$file"
|
||||
done
|
||||
}
|
||||
|
||||
append_to_bashrc aliases.sh bashrc.sh
|
||||
Reference in New Issue
Block a user