#!/bin/bash # Git Aliases Setup for Homelab # Run this script to add helpful git aliases to your shell SHELL_RC="" # Detect shell configuration file if [ -f "$HOME/.bashrc" ]; then SHELL_RC="$HOME/.bashrc" elif [ -f "$HOME/.zshrc" ]; then SHELL_RC="$HOME/.zshrc" else echo "Could not find .bashrc or .zshrc" echo "Please add these aliases manually to your shell configuration" exit 1 fi echo "Adding git aliases to: $SHELL_RC" echo "" # Check if aliases already exist if grep -q "# Homelab Git Aliases" "$SHELL_RC" 2>/dev/null; then echo "Aliases already exist in $SHELL_RC" echo "Remove the '# Homelab Git Aliases' section if you want to re-add them" exit 0 fi # Add aliases cat >> "$SHELL_RC" << 'EOF' # Homelab Git Aliases # Added by git-aliases.sh alias ghome='cd /home/jramos/homelab' alias gs='git status' alias ga='git add' alias gc='git commit -m' alias gl='git log --oneline' alias gll='git log --oneline --graph --all' alias gd='git diff' alias gds='git diff --staged' alias gco='git checkout' alias gb='git branch' # Homelab-specific aliases alias homelab-status='cd /home/jramos/homelab && git status' alias homelab-commit='cd /home/jramos/homelab && git add . && git commit' alias homelab-log='cd /home/jramos/homelab && git log --oneline -10' alias homelab-sync='rsync -av --exclude=.git /mnt/c/Users/fam1n/Documents/homelab/ /home/jramos/homelab/' EOF echo "✓ Aliases added successfully!" echo "" echo "Aliases added:" echo " ghome - cd to homelab directory" echo " gs - git status" echo " ga - git add" echo " gc - git commit -m" echo " gl - git log (compact)" echo " gll - git log (graph)" echo " gd - git diff" echo " gds - git diff --staged" echo " gco - git checkout" echo " gb - git branch" echo "" echo " homelab-status - Quick status check" echo " homelab-commit - Add all and commit" echo " homelab-log - View recent commits" echo " homelab-sync - Sync from Windows location" echo "" echo "To activate now, run:" echo " source $SHELL_RC" echo "" echo "Or simply open a new terminal window"