Skip to content

Instantly share code, notes, and snippets.

@vool
Created May 6, 2020 12:03
Show Gist options
  • Save vool/4af02ec0af1dc9296c26f3ad54795bd5 to your computer and use it in GitHub Desktop.
Save vool/4af02ec0af1dc9296c26f3ad54795bd5 to your computer and use it in GitHub Desktop.
This script searches a directory for a git repos and outputs info for each
#!/bin/bash
# This script searches a directory for a git repos and outputs info for each
#Set colours
BLUE="\e[01;34m"
RED="\e[01;31m"
GREEN="\e[01;32m"
NORMAL='\e[00m'
# Set search dir
DIR=${1:-.}
echo -e "${BLUE}Scanning ${RED}$DIR${BLUE} for git repos ${NORMAL}"
find $DIR -name .git -type d -prune | while read d; do
cd $d/..
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
# List repo
echo -e "\n${BLUE}Repo:${NORMAL}"
echo -e "\t$PWD/.git"
# List Remotes
echo -e "\n${GREEN}Remotes:${NORMAL}"
git remote -v | sed 's/^/\t/'
# List Commits
echo -e "\n${RED}Last Commit:${NORMAL}"
git log -1 --oneline | sed 's/^/\t/'
echo -e
cd $OLDPWD
done
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment