Skip to content
Browse files

Parse git tags as well as git branch

  • Loading branch information...
1 parent 3f41cdc commit 39a872e4a7054af159b15983d8fac9c8b4110aaa @bryanjswift committed Mar 27, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 config/bash_login
View
7 config/bash_login
@@ -2,14 +2,17 @@
function get_git_branch {
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 {
[[ 0 -eq `git status --porcelain | wc -l` ]] || echo "*"
}
function get_git_prompt {
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 {
PS1="\h\[\033[0;33m\] \w\[\033[00m\]\$(get_git_prompt): "
PS2='> '

0 comments on commit 39a872e

Please sign in to comment.
Something went wrong with that request. Please try again.