Skip to content

Instantly share code, notes, and snippets.

@mrmachine
Last active March 8, 2016 22:54
Show Gist options
  • Save mrmachine/e33435c53a0ef9873b17 to your computer and use it in GitHub Desktop.
Save mrmachine/e33435c53a0ef9873b17 to your computer and use it in GitHub Desktop.
Short git status for current directory and all repos in `$VIRTUAL_ENV` directory.
git_status() {
STATUS=$(git status -s 2> /dev/null)
LOCAL=$(git rev-parse "@" 2> /dev/null)
UPSTREAM=$(git rev-parse "@{u}" 2> /dev/null)
if [[ -n $STATUS ]] || ([[ -n $UPSTREAM ]] && [[ $LOCAL != $UPSTREAM ]]); then
git status -bs
fi
}
venv_git_status() {
[[ ! -d "$VIRTUAL_ENV" ]] && return
DIR="$PWD"
for repo in $(find "$VIRTUAL_ENV" -type d -name .git); do
cd $(dirname "$repo")
if [[ -n $(git_status) ]]; then
echo
echo "$PWD"
git_status
echo
fi
done
cd "$DIR"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment