dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

global-git-status (995B)


      1 #!/usr/bin/env bash
      2 # Gives git status output for all git repositories on the system.
      3 spin() {
      4     sp='/-\|'
      5     printf ' '
      6     while true; do
      7         # Print backspace, field of width 1
      8         printf '\b%.1s' "$sp"
      9 
     10         # Move first character to end
     11         sp=${sp#?}${sp%???}
     12         sleep 0.05
     13     done
     14 }
     15 hr() { for ((i=0; i<$(tput cols); i++)); do echo -n "#"; done; echo; }
     16 cleanup() {
     17   kill $pid
     18   exit 2
     19 }
     20 
     21 spin &
     22 pid=$!
     23 
     24 trap cleanup INT
     25 echo "Looking for git repositories..."
     26 logfile="$(mktemp)"
     27 gits=$(find "$HOME" -name ".git" -not -path "*vim*plugged*" 2>/dev/null)
     28 
     29 kill $pid &> /dev/null
     30 trap - INT
     31 count=0
     32 echo -ne '\r'
     33 
     34 IFS=$'\n'
     35 for i in ${gits[@]}; do
     36   ((count++))
     37   echo -ne "Processed $count\r"
     38   echo "git: $i" >> $logfile;
     39   cd "$i/../" &>/dev/null;
     40   git fetch --all &> /dev/null;
     41   git status >> $logfile;
     42   hr >> $logfile;
     43 done
     44 echo
     45 vim $logfile -c "let @d=\"j?^git: 
V/#
d\"" -c "w|1" --cmd "echo 'Execute register D to remove a status report.'"
     46 unset IFS
     47 clear