From 45fddb4517a87758a5ec3ed1d79eeb0b15112d72 Mon Sep 17 00:00:00 2001 From: nojhan Date: Mon, 13 Aug 2012 22:23:43 +0200 Subject: [PATCH] feature #25 : unicode chars only for utf-8 charset, else latin --- liquidprompt | 20 ++++++++++++++------ liquidpromptrc-dist | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/liquidprompt b/liquidprompt index 4f99ed3..f13ef89 100755 --- a/liquidprompt +++ b/liquidprompt @@ -74,6 +74,14 @@ LP_PATH_KEEP=${LP_PATH_KEEP:-2} LP_REVERSE=${LP_REVERSE:-0} LP_HOSTNAME_ALWAYS=${LP_HOSTNAME_ALWAYS:-0} LP_PS1=${LP_PS1:-""} +LP_BATTERY_MARK=${LP_BATTERY_MARK:-"⌁"} +LP_ADAPTER_MARK=${LP_ADAPTER_MARK:-""} +LP_LOAD_MARK=${LP_LOAD_MARK:-"⌂"} +LP_PROXY_MARK=${LP_PROXY_MARK:-"↥"} +LP_GIT_MARK=${LP_GIT_MARK:-"±"} +LP_MERCURIAL_MARK=${LP_MERCURIAL_MARK:-"☿"} +LP_SUBVERSION_MARK=${LP_SUBVERSION_MARK:-"‡"} + # Default config file may be the XDG standard ~/.config/liquidpromptrc, # but heirloom dotfile has priority. @@ -312,7 +320,7 @@ __host_color() __proxy() { if [[ ! -z "$http_proxy" ]] ; then - echo -ne "↥" + echo -ne $LP_PROXY_MARK fi } @@ -666,7 +674,7 @@ __battery() # a red ⌁ if the battery is discharging but above threshold __battery_color() { - local mark="⌁" + local mark=$LP_BATTERY_MARK local bat local ret bat=$(__battery) @@ -740,7 +748,7 @@ __load_color() if [[ $load -ge $LP_LOAD_THRESHOLD ]] then - ret="⌂${NO_COL}" + ret="${LP_LOAD_MARK}${NO_COL}" if [[ $load -lt 70 ]] ; then ret="${ret}${FG}" elif [[ $load -ge 1 ]] && [[ $load -lt 80 ]] ; then @@ -778,11 +786,11 @@ __smart_mark() mark="%(!.#.$)" fi if [[ ! -z $(__git_branch) ]] ; then - mark="±" + mark=$LP_GIT_MARK elif [[ ! -z $(__hg_branch) ]] ; then - mark="☿" + mark=$LP_MERCURIAL_MARK elif [[ ! -z $(__svn_branch) ]] ; then - mark="‡" + mark=$LP_SUBVERSION_MARK fi echo -ne "${COL}${mark}${NO_COL}" } diff --git a/liquidpromptrc-dist b/liquidpromptrc-dist index d6d067d..66d8324 100644 --- a/liquidpromptrc-dist +++ b/liquidpromptrc-dist @@ -29,3 +29,21 @@ LP_REVERSE=0 # set to 1 if you want to always see the hostname LP_HOSTNAME_ALWAYS=0 +# If charset is UTF-8 +if [[ $(locale -k LC_CTYPE | sed -n 's/^charmap="\(.*\)"/\1/p') == *"UTF-8"* ]] ; then + LP_BATTERY_MARK="⌁" + LP_ADAPTER_MARK="" + LP_LOAD_MARK="⌂" + LP_PROXY_MARK="↥" + LP_GIT_MARK="±" + LP_MERCURIAL_MARK="☿" + LP_SUBVERSION_MARK="‡" +else + LP_BATTERY_MARK="b" + LP_ADAPTER_MARK="p" + LP_LOAD_MARK="c" + LP_PROXY_MARK="^" + LP_GIT_MARK="+" + LP_MERCURIAL_MARK="m" + LP_SUBVERSION_MARK="=" +fi