From 0943eb67a960225ed8900903d908e9d335cfcdb5 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Aug 2012 14:40:50 +0200 Subject: [PATCH] =?UTF-8?q?Different=20prompt=20mark=20for=20different=20V?= =?UTF-8?q?CS=20(=C2=B1,=20=E2=98=BF,=20=E2=80=A1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ± for git directories, ☿ for mercurial, ‡ for svn. Thus, do not display the now useless letter prefix before the branch name. Refactor the smart mark function. --- README.md | 5 +++-- liquidprompt.bash | 36 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index fe341c1..d817c16 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ in a git repository on a server, at branch "myb": A liquid prompt displaying everything may look like this: -`⌁24% ⌂42% 3d/2&/1z [user@server:~/ … /code/liquidprompt]↥ g·master(+10/-5,3) 125 ± ` +`⌁24% ⌂42% 3d/2&/1z [user@server:~/ … /code/liquidprompt]↥ master(+10/-5,3) 125 ± ` It displays: @@ -52,7 +52,8 @@ there is changes, in yellow if there is pending commits to push; * the number of added/deleted lines, if changes have been made and the number of pending commits, if any; * the error code of the last command, if it has failed in some way; -* a smart mark: ± for VCS directories, $ for simple user, a red # for root. +* a smart mark: ± for git directories, ☿ for mercurial, ‡ for svn, $ for simple +user, a red # for root. You can temporarily deactivate the liquid prompt and come back to your previous one by typing `prompt_off`. Use `prompt_on` to bring it back. diff --git a/liquidprompt.bash b/liquidprompt.bash index 1caa9b5..9a78a63 100755 --- a/liquidprompt.bash +++ b/liquidprompt.bash @@ -502,7 +502,7 @@ __git_branch_color() ret="${GREEN}${branch}${NO_COL}" # nothing to commit or push fi fi - echo -ne "g·$ret" + echo -ne "$ret" fi } @@ -532,7 +532,7 @@ __hg_branch_color() else ret="${RED}${branch}${NO_COL}" # changes to commit fi - echo -ne "h·$ret" + echo -ne "$ret" fi } @@ -573,7 +573,7 @@ __svn_branch_color() else ret="${RED}${branch}${NO_COL}(${YELLOW}$commits${NO_COL})" # changes to commit fi - echo -ne "s·$ret" + echo -ne "$ret" fi } @@ -675,24 +675,24 @@ __load_color() # DESIGN # ########## -# Set the prompt mark to ± if VCS, # if root and else $ -# FIXME use the mercury unicode char for mercurial +# Set the prompt mark to ± if git, to ☿ if mercurial, to ‡ if subversion +# to # if root and else $ __smart_mark() { - if [[ "$EUID" -ne "0" ]] - then - if [[ ! -z $(__git_branch) ]] || [[ ! -z $(__hg_branch) ]] || [[ ! -z $(__svn_branch) ]] ; then - echo -ne "${BOLD_FG}±${NO_COL}" - else - echo -ne "${BOLD_FG}\\\$${NO_COL}" - fi - else - if [[ ! -z $(__git_branch) ]] || [[ ! -z $(__hg_branch) ]] || [[ ! -z $(__svn_branch) ]] ; then - echo -ne "${BOLD_RED}±${NO_COL}" - else - echo -ne "${BOLD_RED}#${NO_COL}" - fi + local COL=${BOLD_FG} + if [[ "$EUID" -eq "0" ]] ; then + COL=${BOLD_RED} fi + + local mark="\\\$" + if [[ ! -z $(__git_branch) ]] ; then + mark="±" + elif [[ ! -z $(__hg_branch) ]] ; then + mark="☿" + elif [[ ! -z $(__svn_branch) ]] ; then + mark="‡" + fi + echo -ne "${COL}${mark}${NO_COL}" } # insert a space on the right