Skip to content

Commit

Permalink
Parse git tags as well as git branch
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjswift committed Mar 27, 2013
1 parent 3f41cdc commit 39a872e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions config/bash_login
Expand Up @@ -2,14 +2,17 @@
function get_git_branch { function get_git_branch {
git branch | awk '/^\*/ { print substr($0, 3, (length - 2)) }' git branch | awk '/^\*/ { print substr($0, 3, (length - 2)) }'
} }
function get_git_tag {
git name-rev HEAD --tags --name-only | awk '/\^0$/ { printf " ["; printf substr($0, 1, length - 2); print "]"; }'
}
function get_git_dirty { function get_git_dirty {
[[ 0 -eq `git status --porcelain | wc -l` ]] || echo "*" [[ 0 -eq `git status --porcelain | wc -l` ]] || echo "*"
} }
function get_git_prompt { function get_git_prompt {
git branch &> /dev/null || return 1 git branch &> /dev/null || return 1
echo "[$(get_git_branch)$(get_git_dirty)]" echo "$(get_git_tag) ($(get_git_branch)$(get_git_dirty))"
} }

function gitPrompt { function gitPrompt {
PS1="\h\[\033[0;33m\] \w\[\033[00m\]\$(get_git_prompt): " PS1="\h\[\033[0;33m\] \w\[\033[00m\]\$(get_git_prompt): "
PS2='> ' PS2='> '
Expand Down

0 comments on commit 39a872e

Please sign in to comment.