From 81bc91d4dcd75630deefdd7455ff477b34c3dc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Sun, 5 May 2013 00:34:03 +0200 Subject: [PATCH 1/2] Optimize _lp_sl/sr/sb --- liquidprompt | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/liquidprompt b/liquidprompt index 352b2b2..6520035 100755 --- a/liquidprompt +++ b/liquidprompt @@ -1325,26 +1325,19 @@ _lp_smart_mark() # insert a space on the right _lp_sr() { - if [[ ! -z "$1" ]] ; then - echo -n "$1 " - fi + [[ -n "$1" ]] && echo -n "$1 " } # insert a space on the left _lp_sl() { - if [[ ! -z "$1" ]] ; then - echo -n " $1" - fi + [[ -n "$1" ]] && echo -n " $1" } # insert two space, before and after _lp_sb() { - if [[ ! -z "$1" ]] ; then - echo -n " $1 " - fi - + [[ -n "$1" ]] && echo -n " $1 " } ################### From cc6c0e8d206e1146e6c7177a268784dcd83d64d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Sun, 5 May 2013 00:35:38 +0200 Subject: [PATCH 2/2] s/if [[ ! -z /if [[ -n / --- liquidprompt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/liquidprompt b/liquidprompt index 6520035..79e08cb 100755 --- a/liquidprompt +++ b/liquidprompt @@ -711,7 +711,7 @@ _lp_git_branch_color() local branch branch=$(_lp_git_branch) - if [[ ! -z "$branch" ]] ; then + if [[ -n "$branch" ]] ; then local GD git diff --quiet >/dev/null 2>&1 @@ -803,7 +803,7 @@ _lp_hg_branch_color() local branch local ret branch=$(_lp_hg_branch) - if [[ ! -z "$branch" ]] ; then + if [[ -n "$branch" ]] ; then local has_untracked has_untracked=$(hg status 2>/dev/null | grep '\(^\?\)' | wc -l) @@ -921,7 +921,7 @@ _lp_fossil_branch_color() local branch branch=$(_lp_fossil_branch) - if [[ ! -z "$branch" ]] ; then + if [[ -n "$branch" ]] ; then local C2E # Modified files (added or edited) local C2D # Deleted files local C2A # Extras files @@ -1000,7 +1000,7 @@ _lp_bzr_branch_color() local revno=${tuple[1]} local clean=${tuple[2]} - if [[ ! -z "$branch" ]] ; then + if [[ -n "$branch" ]] ; then if [[ "$clean" -eq 0 ]] ; then ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_COMMITS}$revno${NO_COL})" else