Last active
December 26, 2015 13:28
-
-
Save rafaeldff/7158274 to your computer and use it in GitHub Desktop.
Status overview for multiple git repositories
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
#! /bin/bash | |
normal=$(tput sgr0) | |
red=$(tput setaf 1) | |
green=$(tput setaf 2) | |
lime_yellow=$(tput setaf 190) | |
REVERSE=$(tput smso) | |
function column-err { | |
#printf "${REVERSE}${red}%-8s${normal}" "$1" | |
printf "\033[41m%-10s\033[0m" "$1" | |
} | |
function column-ok { | |
printf "\033[32m%-10s\033[0m" "$1" | |
} | |
function column-heading { | |
printf "\e[48;5;237m%-19s\e[0m" "$1" | |
} | |
function proj_name() { | |
column-heading $(pwd | sed 's,^.*/,,') | |
} | |
function dirty_state() { | |
if ( ! git diff --no-ext-diff --quiet --exit-code ) || | |
git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null | |
then | |
column-err "dirty" | |
else | |
column-ok "clean" | |
fi | |
} | |
function local_state() { | |
__git_ps1_show_upstream | |
case $p in | |
"<>" | ">") | |
column-err "To push" | |
;; | |
*) | |
column-ok "push ok" | |
;; | |
esac | |
} | |
function remote_state() { | |
__git_ps1_show_upstream | |
case $p in | |
"<>" | "<") | |
column-err "To pull" | |
;; | |
*) | |
column-ok "pull ok" | |
;; | |
esac | |
} | |
function project_status() { | |
pushd $1/.. > /dev/null | |
proj_name; | |
git fetch 1> /dev/null 2> /dev/null | |
dirty_state; local_state; remote_state; | |
echo | |
popd > /dev/null | |
} | |
export -f __git_ps1_show_upstream | |
export -f column-err | |
export -f column-ok | |
export -f column-heading | |
export -f proj_name | |
export -f dirty_state | |
export -f local_state | |
export -f remote_state | |
export -f project_status | |
function gallstatus() { | |
find . -type d -name '.git' -exec bash -c "project_status {}" \; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Needs git-prompt.sh to be sourced.