39 lines
1.2 KiB
Bash
Executable file
39 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
# --- Git-Toolbox: Hybrider Zweig-Navigator ---
|
|
|
|
# 1. Zweige einlesen
|
|
branches=($(git branch --format='%(refname:short)'))
|
|
current=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
# 2. Check: Wurde das Skript mit dem Argument --gui aufgerufen?
|
|
if [[ "$1" == "--gui" ]]; then
|
|
# --- GUI MODUS (Zenity) ---
|
|
# Wir erstellen eine Liste für Zenity, wobei der aktuelle Branch markiert ist
|
|
CHOICE=$(zenity --list \
|
|
--title="Zweig wechseln" \
|
|
--column="Zweige" \
|
|
"${branches[@]}" \
|
|
--width=300 --height=400)
|
|
|
|
if [ -n "$CHOICE" ]; then
|
|
git checkout "$CHOICE"
|
|
zenity --info --text="Gewechselt zu $CHOICE" --timeout=2
|
|
fi
|
|
else
|
|
# --- TERMINAL MODUS (Klassisch) ---
|
|
echo "--- Verfügbare Zweige ---"
|
|
for i in "${!branches[@]}"; do
|
|
if [[ "${branches[$i]}" == "$current" ]]; then
|
|
echo " [$i] ${branches[$i]} (AKTUELL)"
|
|
else
|
|
echo " [$i] ${branches[$i]}"
|
|
fi
|
|
done
|
|
echo "--------------------------"
|
|
read -p "Nummer eingeben: " choice
|
|
if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -lt "${#branches[@]}" ]; then
|
|
git checkout "${branches[$choice]}"
|
|
else
|
|
echo "Ungültige Wahl."
|
|
fi
|
|
fi
|