#!/usr/bin/env bash set -euo pipefail WORKDIR="$HOME/Work" terminal="alacritty" # Colors GREEN="\e[1;32m" CYAN="\e[1;36m" YELLOW="\e[1;33m" RESET="\e[0m" #Start script cd "$WORKDIR" echo "" echo -e "${CYAN}Updating repositories...${RESET}" echo -e "${YELLOW}------------------------${RESET}" echo "" # Update all git repos for gitdir in */.git; do [ -d "$gitdir" ] || continue repo="${gitdir%/.git}" echo -e "Updating ${CYAN}$repo${RESET}" git -C "$repo" pull --ff-only || true echo "" done echo "" echo -e "${GREEN}Update complete.${RESET}" dunstify -h string:x-dunst-stack-tag:git "Git Update" "All repositories has been updated" sleep 0.5 # Find all git repositories repos=$(find "$WORKDIR" -mindepth 1 -maxdepth 1 -type d \ -exec test -d "{}/.git" \; -print \ | xargs -n1 basename \ | sort) # Add "Exit" option at the top menu=$(printf "Exit\n%s\n" "$repos") # Launch fzf selector repo=$(printf "%s\n" "$menu" | fzf \ --prompt="Select repo > " \ --height=35% \ --border=rounded\ --tmux \ --exit-0) # Exit if nothing selected or "Exit" chosen [ -z "${repo:-}" ] && exit 0 [ "$repo" = "Exit" ] && exit 0 dir="$WORKDIR/$repo" echo "" echo -e "Opening ${CYAN}$repo${RESET}..." echo "" # Create tmux session if it doesn't exist tmux has-session -t "$repo" 2>/dev/null || \ tmux new-session -d -s "$repo" -c "$dir" # Launch new terminal detached nohup "$terminal" -e tmux attach -t "$repo" >/dev/null 2>&1 & exit 0