From d8d91c2ea86abd7b3343cd3853b95181155e81ac Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Tue, 4 Jan 2011 15:00:05 +0100 Subject: [Prompts/Func] Get Mercurial branch --- 01_Functions.zsh | 26 ++++++++++++++++++++++---- 12_Prompts.zsh | 10 ++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/01_Functions.zsh b/01_Functions.zsh index 0e236e2..b189e87 100644 --- a/01_Functions.zsh +++ b/01_Functions.zsh @@ -112,14 +112,32 @@ preprint() fi } -get_git_branch () +get_gcl_branch () { - local my_git_branch checkouted_branch="yes" + case $1 in + git) + get_git_branch + ;; + hg) + get_hg_branch + ;; + *) + ;; + esac +} - if [ ! -z "$DO_NOT_CHECK_GIT_BRANCH" ] +get_hg_branch () +{ + HGROOT=$(hg root 2>/dev/null) + if [ ! -z "$HGROOT" ] then - return + hg branch fi +} + +get_git_branch () +{ + local my_git_branch checkouted_branch="yes" if [ -f ".repo/manifests.git/config" ] then diff --git a/12_Prompts.zsh b/12_Prompts.zsh index 47aecc7..d3c914f 100644 --- a/12_Prompts.zsh +++ b/12_Prompts.zsh @@ -240,10 +240,16 @@ update_prompt_elements() SVNREV=${SVNREV:+$C_$prompt_colors[doubledot]$_C $C_$SVNSTATUS$_C"r"$SVNREV} [ "$DEBUG" = "yes" ] && echo + # get hg status + [ "$DEBUG" = "yes" ] && echo -n " HG status..." + HGBRANCH=$(get_gcl_branch hg) + [ ! -z "$HGBRANCH" ] && HGBRANCH=" "$HGBRANCH + [ "$DEBUG" = "yes" ] && echo + # get git status # [ "$DEBUG" = "yes" ] && echo -n " GIT status..." - GITBRANCH=$(get_git_branch) + GITBRANCH=$(get_gcl_branch git) GITBRANCHSIZE=${#GITBRANCH} [ $GITBRANCHSIZE -gt 0 ] && GITBRANCHSIZE=$(($GITBRANCHSIZE)) [ "$DEBUG" = "yes" ] && echo @@ -319,7 +325,7 @@ two_lines_prompt () ## Le prompt le plus magnifique du monde, et c'est le mien ! # Affiche l'user, l'host, le tty et le pwd. Rien que ça... PS1=$AGENTS$MAILSTAT$ERROR$BATTERY$C_$prompt_colors[bar]$_C$STLINUX$HBAR$DATE" -"$C_"30;1"$_C$SHLVL"-"$C_$prompt_color[default]$_C$C_$prompt_colors[user]$_C"%n"$C_$prompt_colors[arob]$_C"@"$C_$prompt_colors[host]$_C"%m "$CURDIR$CVSTAG$SVNREV$GITBRANCH" "$C_$prompt_colors[dies]$_C"%#"$C_$prompt_colors[cmd]$_C" " +"$C_"30;1"$_C$SHLVL"-"$C_$prompt_color[default]$_C$C_$prompt_colors[user]$_C"%n"$C_$prompt_colors[arob]$_C"@"$C_$prompt_colors[host]$_C"%m "$CURDIR$CVSTAG$SVNREV$GITBRANCH$HGBRANCH" "$C_$prompt_colors[dies]$_C"%#"$C_$prompt_colors[cmd]$_C" " } -- cgit v1.2.3