git-notify: Shell-Start-Benachrichtigung bei Remote-Updates

Neues Skript bin/git-notify.sh prüft beim interaktiven Shell-Start
im Hintergrund alle Repos auf neue Remote-Commits (git fetch + count).
Gibt nur eine Zeile aus wenn Updates vorhanden, sonst kein Output.
Nutzer steuert Aktualisierung selbst via gitsync.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
rene 2026-03-27 14:01:48 +01:00
parent 562ebb64f2
commit cbfda7a410
2 changed files with 54 additions and 0 deletions

49
bin/git-notify.sh Executable file
View file

@ -0,0 +1,49 @@
#!/usr/bin/env bash
# git-notify.sh — prüft beim Shell-Start ob Remote-Commits verfügbar sind.
# Läuft im Hintergrund, gibt nur eine Zeile aus wenn Updates vorhanden.
# Kein Output wenn alles aktuell ist.
BASE_DIR="${BASE_DIR:-$HOME/git-projekte}"
GITEA_BASE="https://git.motocamp.de/rene"
REPO_NAMES=(
balkonsteuerung
berechnungstabellen
claude-skills
comfy
dotfiles-rene
esp32
ki-agenten
macbook-setup
Pi_pico_2w
portainer
skripte
test
web
zellenhalter-generator
)
C_YELLOW=$'\033[33m'
C_CYAN=$'\033[36m'
C_BOLD=$'\033[1m'
C_RESET=$'\033[0m'
updates=()
for NAME in "${REPO_NAMES[@]}"; do
TARGET="$BASE_DIR/$NAME"
[ -d "$TARGET/.git" ] || continue
cd "$TARGET" || continue
git fetch --quiet 2>/dev/null || continue
behind=$(git rev-list --count "HEAD..@{u}" 2>/dev/null || echo 0)
(( behind > 0 )) && updates+=("$NAME ($behind)")
done
if (( ${#updates[@]} > 0 )); then
names=$(printf '%s, ' "${updates[@]}")
names="${names%, }"
printf "\n${C_YELLOW}📥 Git-Updates verfügbar${C_RESET} ${C_BOLD}%s${C_RESET}\n" "$names"
printf " ${C_CYAN}→ gitsync${C_RESET} zum Aktualisieren\n\n"
fi

View file

@ -284,6 +284,11 @@ if [[ -o interactive ]] && command -v cowsay &>/dev/null; then
unfunction _greet
fi
# Git-Updates beim Shell-Start prüfen (Hintergrund, kein Output wenn alles aktuell)
if [[ -o interactive ]] && [[ -f "$HOME/git-projekte/dotfiles-rene/bin/git-notify.sh" ]]; then
("$HOME/git-projekte/dotfiles-rene/bin/git-notify.sh" &)
fi
alias gitsync="~/git-projekte/dotfiles-rene/bin/git-sync-all.sh"
alias mac-sync="curl -fsSL https://git.motocamp.de/rene/dotfiles-rene/raw/branch/main/bin/git-sync-all.sh | bash"