From: Ryan Date: Wed, 1 Jun 2011 04:41:07 +0000 (-1000) Subject: Added hg dirty/clean modifier X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=aa2f1cbeb7141a24d154de15b35f3f51914f285a;p=common%2Fbash_it.git Added hg dirty/clean modifier --- diff --git a/themes/hawaii50/hawaii50.theme.bash b/themes/hawaii50/hawaii50.theme.bash index 987153b..656649b 100644 --- a/themes/hawaii50/hawaii50.theme.bash +++ b/themes/hawaii50/hawaii50.theme.bash @@ -32,6 +32,16 @@ HG_THEME_PROMPT_SUFFIX='|' # Use http://geoff.greer.fm/lscolors/ +# Override function scm +function scm { + if [[ -d .git ]]; then SCM=$GIT + elif [[ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]]; then SCM=$GIT + elif [[ -n "$(hg summary 2> /dev/null)" ]]; then SCM=$HG + elif [[ -d .svn ]]; then SCM=$SVN + else SCM='NONE' + fi +} + # Displays the current virtualenv information function curr_virtualenv_info() { [ ! -z "$VIRTUAL_ENV" ] && echo "`basename $VIRTUAL_ENV`" @@ -90,21 +100,22 @@ function parse_git_info() { ref=$(git symbolic-ref HEAD 2> /dev/null) || return rawhex=$(git rev-parse HEAD 2>/dev/null) || return - echo "$prefix${ref#refs/heads/}=#${rawhex:0:$MAX_GIT_HEX_LENGTH}$state$suffix" + echo "$prefix${ref#refs/heads/}:${rawhex:0:$MAX_GIT_HEX_LENGTH}$state$suffix" } # Parse hg info function parse_hg_info() { - if [[ -n $(hg status --no-color 2> /dev/null| awk '$1 == "?" { print "?" } $1 = "?" { print "!" }' | sort | uniq | head -c1) ]]; then + if [[ -n $(hg status 2> /dev/null) ]]; then state=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else state=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} fi prefix=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} suffix=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} - branch=$(hg branch 2> /dev/null | awk '{print $1}') + branch=$(hg summary 2> /dev/null | grep branch | awk '{print $2}') + changeset=$(hg summary 2> /dev/null | grep parent | awk '{print $2}') - echo "$prefix$branch$state$suffix" + echo "$prefix${branch}:${changeset#*:}$state$suffix" }