Skip to content

Instantly share code, notes, and snippets.

@sebastianneubert
Created August 11, 2020 13:47
Show Gist options
  • Save sebastianneubert/9e249d859adcbcdadd810bdf5df0e162 to your computer and use it in GitHub Desktop.
Save sebastianneubert/9e249d859adcbcdadd810bdf5df0e162 to your computer and use it in GitHub Desktop.
check git branches in all sub dirs
#!/bin/bash +e
#0 black COLOR_BLACK 0,0,0
#1 red COLOR_RED 1,0,0
#2 green COLOR_GREEN 0,1,0
#3 yellow COLOR_YELLOW 1,1,0
#4 blue COLOR_BLUE 0,0,1
#5 magenta COLOR_MAGENTA 1,0,1
#6 cyan COLOR_CYAN 0,1,1
#7 white COLOR_WHITE 1,1,1
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
cyan=`tput setaf 6`
reset=`tput sgr0`
dirs=($(find . -maxdepth 1 -type d \( ! -name . \) ))
for dir in "${dirs[@]}"; do
echo "${cyan}-------------------------${reset}"
cd "$dir"
if [[ -d ".git" ]]; then
branch=$(git rev-parse --abbrev-ref HEAD)
echo "${green}$branch${reset} - $dir$";
else
continue
fi
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment