From bec0715e40574a65b52e1210456e85315bf505de Mon Sep 17 00:00:00 2001 From: bmallred Date: Mon, 23 Dec 2013 07:24:57 -0500 Subject: [PATCH] Updated BZR prompt info and added HG prompt info. --- lib/bzr.zsh | 21 +++++++++++++++------ lib/hg.zsh | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 lib/hg.zsh diff --git a/lib/bzr.zsh b/lib/bzr.zsh index 005a1650..b9706b42 100644 --- a/lib/bzr.zsh +++ b/lib/bzr.zsh @@ -1,10 +1,19 @@ ## Bazaar integration ## Just works with the GIT integration just add $(bzr_prompt_info) to the PROMPT function bzr_prompt_info() { - BZR_CB=`bzr nick 2> /dev/null | grep -v "ERROR" | cut -d ":" -f2 | awk -F / '{print "bzr::"$1}'` - if [ -n "$BZR_CB" ]; then - BZR_DIRTY="" - [[ -n `bzr status` ]] && BZR_DIRTY=" %{$fg[red]%} * %{$fg[green]%}" - echo "$ZSH_THEME_SCM_PROMPT_PREFIX$BZR_CB$BZR_DIRTY$ZSH_THEME_GIT_PROMPT_SUFFIX" + BZR_BRANCH=$(command bzr nick 2> /dev/null | grep -v "ERROR" | cut -d ":" -f2 | awk -F / '{print $1}') + + if [[ -n "$BZR_CB" ]]; then + echo "$ZSH_THEME_SCM_PROMPT_PREFIX$BZR_BRANCH$(parse_bzr_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" fi -} \ No newline at end of file +} + +function parse_bzr_dirty() { + BZR_STATUS=$(command bzr status 2> /dev/null | tail -n1) + + if [[ -n "$BZR_STATUS" ]]; then + echo $ZSH_THEME_GIT_PROMPT_DIRTY + else + echo $ZSH_THEME_GIT_PROMPT_CLEAN + fi +} diff --git a/lib/hg.zsh b/lib/hg.zsh new file mode 100644 index 00000000..d6df4322 --- /dev/null +++ b/lib/hg.zsh @@ -0,0 +1,18 @@ +## Mercurial (Hg) integration +function hg_prompt_info() { + HG_BRANCH=$(command hg branch 2> /dev/null | grep -v ^abort) + + if [[ -n "$HG_CB" ]]; then + echo "$ZSH_THEME_HG_PROMPT_PREFIX$HG_BRANCH$(parse_hg_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" + fi +} + +function parse_hg_dirty() { + HG_STATUS=$(command hg status 2> /dev/null | tail -n1) + + if [[ -n "$HG_STATUS" ]]; then + echo $ZSH_THEME_GIT_PROMPT_DIRTY + else + echo $ZSH_THEME_GIT_PROMPT_CLEAN + fi +}