Last active
April 4, 2023 01:21
-
-
Save xgvargas/68f13e96f6db782bd064ba69a817ddde to your computer and use it in GitHub Desktop.
List GIT status of all sub directories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/bash | |
if [ -t 1 ]; then | |
# executed in terminal | |
GREY='\e[1;30m' | |
RED='\e[1;31m' | |
GREEN='\e[1;32m' | |
YELLOW='\e[1;33m' | |
BLUE='\e[1;34m' | |
MARGENTA='\e[1;35m' | |
CYAN='\e[1;36m' | |
WHITE='\e[1;37m' | |
NONE='\e[0m' | |
fi | |
basic_info_f() { | |
local name="$1" | |
if [[ -d $name/.git ]]; then | |
cd $name | |
stat="" | |
[ ! -z "$(git status --porcelain)" ] && stat="$stat${RED}Dirty " | |
[ ! -z "$(git cherry 2>&1)" ] && stat="$stat${BLUE}Non pushed " | |
[ -z "$stat" ] && stat="${GREEN}Clean" | |
cd - >> /dev/null | |
else | |
stat="${YELLOW}Not GIT" | |
fi | |
printf "%-30s %b${NONE}\n" "$name" "$stat" | |
} | |
find -maxdepth 1 -mindepth 1 -type d | sort | while read dir; do | |
basic_info_f "$dir"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment