35 lines
893 B
Bash
Executable File
35 lines
893 B
Bash
Executable File
#!/bin/bash
|
||
|
||
CATEGORIES_DIR="./Aliases"
|
||
TARGET_FILE="$HOME/.bashrc_aliases"
|
||
|
||
echo "Verfügbare Kategorien:"
|
||
select_files=()
|
||
i=1
|
||
for file in "$CATEGORIES_DIR"/*.sh; do
|
||
filename=$(basename "$file")
|
||
echo " [$i] $filename"
|
||
select_files+=("$file")
|
||
((i++))
|
||
done
|
||
|
||
echo
|
||
read -p "Gib die Nummern der Kategorien ein, getrennt mit Leerzeichen (z. B. '1 3'): " -a choices
|
||
|
||
# Backup alte Datei
|
||
cp "$TARGET_FILE" "${TARGET_FILE}.bak"
|
||
|
||
# Neue Datei erstellen
|
||
> "$TARGET_FILE"
|
||
|
||
for choice in "${choices[@]}"; do
|
||
if [[ "$choice" =~ ^[0-9]+$ ]] && (( choice >= 1 && choice <= ${#select_files[@]} )); then
|
||
cat "${select_files[$((choice-1))]}" >> "$TARGET_FILE"
|
||
echo "" >> "$TARGET_FILE"
|
||
else
|
||
echo "Ungültige Auswahl: $choice"
|
||
fi
|
||
done
|
||
|
||
echo "Aliase aktualisiert in $TARGET_FILE"
|
||
echo "Bitte führe 'source ~/.bashrc_aliases' oder öffne ein neues Terminal." |