Skip to content

Instantly share code, notes, and snippets.

@Integralist
Created February 4, 2016 09:38
Show Gist options
  • Save Integralist/a625dd7d7c0d07bf1ad6 to your computer and use it in GitHub Desktop.
Save Integralist/a625dd7d7c0d07bf1ad6 to your computer and use it in GitHub Desktop.
Simple check for git repo in Bash
function git_environment() {
$(git rev-parse --is-inside-work-tree >& /dev/null)
if [ "$?" -eq "128" ]; then
git_branch=""
else
git_branch=" ($(git branch | grep '^*' | cut -d ' ' -f 2))"
fi
}
echo $git_branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment