Permalink
Browse files

Add theme/prompt support for mercurial plugin, similar to git's

  • Loading branch information...
1 parent 11f441a commit 9500d67708a674fe5c58f4a0f4a47dd8e090dfa0 @aranasaurus committed Jul 11, 2012
Showing with 22 additions and 0 deletions.
  1. +22 −0 plugins/mercurial/mercurial.plugin.zsh
@@ -12,3 +12,25 @@ alias hgp='hg push'
alias hgs='hg status'
# this is the 'git commit --amend' equivalent
alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip'
+
+# Theme vars and functions
+ZSH_THEME_HG_PROMPT_PREFIX="hg:(" # Prefix at the very beginning of the prompt, before the branch name
+ZSH_THEME_HG_PROMPT_SUFFIX=")" # At the very end of the prompt
+ZSH_THEME_HG_PROMPT_DIRTY="*" # Text to display if the branch is dirty
+ZSH_THEME_HG_PROMPT_CLEAN="" # Text to display if the branch is clean
+
+# get the name of the branch we are on
+function hg_prompt_info() {
+ ref=$(hg branch 2> /dev/null) || return
+ echo "$ZSH_THEME_HG_PROMPT_PREFIX${ref}$(parse_hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX"
+}
+
+# Checks if working tree is dirty
+parse_hg_dirty() {
+ if [[ -n $(hg status 2> /dev/null) ]]; then
+ echo "$ZSH_THEME_HG_PROMPT_DIRTY"
+ else
+ echo "$ZSH_THEME_HG_PROMPT_CLEAN"
+ fi
+}
+

0 comments on commit 9500d67

Please sign in to comment.