Created
October 31, 2014 19:10
-
-
Save gnuwilliam/5d3f4b3d371cad7a79d7 to your computer and use it in GitHub Desktop.
Get git branch info - shell
This file contains 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
function parse_git_deleted { | |
[[ $(git status --ignore-submodules 2> /dev/null | grep deleted:) != "" ]] && echo "-" | |
} | |
function parse_git_added { | |
[[ $(git status --ignore-submodules 2> /dev/null | grep "Untracked files:") != "" ]] && echo '+' | |
} | |
function parse_git_modified { | |
[[ $(git status --ignore-submodules 2> /dev/null | grep modified:) != "" ]] && echo "*" | |
} | |
function parse_git_dirty { | |
echo "$(parse_git_added)$(parse_git_modified)$(parse_git_deleted)" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ (\1$(parse_git_dirty))/" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment