From cbfda7a41087591f7625ff21ca90adc827e0a037 Mon Sep 17 00:00:00 2001 From: rene Date: Fri, 27 Mar 2026 14:01:48 +0100 Subject: [PATCH] git-notify: Shell-Start-Benachrichtigung bei Remote-Updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- bin/git-notify.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++ zsh/.zshrc | 5 +++++ 2 files changed, 54 insertions(+) create mode 100755 bin/git-notify.sh diff --git a/bin/git-notify.sh b/bin/git-notify.sh new file mode 100755 index 0000000..f43c8c2 --- /dev/null +++ b/bin/git-notify.sh @@ -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 diff --git a/zsh/.zshrc b/zsh/.zshrc index 88d8184..d3467a6 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -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"