From 58bae6f900ce81c4f8777a9265b149c21b265627 Mon Sep 17 00:00:00 2001 From: Darren Bishop Date: Mon, 28 Nov 2022 14:52:34 +0000 Subject: [PATCH 1/5] Fix call to liquidprompt function Missing leading underscore in `_lp_escape` --- themes/liquidprompt/liquidprompt.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/liquidprompt/liquidprompt.theme.bash b/themes/liquidprompt/liquidprompt.theme.bash index 60e64210..c458ad4a 100644 --- a/themes/liquidprompt/liquidprompt.theme.bash +++ b/themes/liquidprompt/liquidprompt.theme.bash @@ -39,7 +39,7 @@ _lp_git_branch() # Recent versions of Git support the --short option for symbolic-ref, but # not 1.7.9 (Ubuntu 12.04) if branch="$(\git symbolic-ref -q HEAD)"; then - _lp_escape "$(\git rev-parse --short=5 -q HEAD 2>/dev/null):${branch#refs/heads/}" + __lp_escape "$(\git rev-parse --short=5 -q HEAD 2>/dev/null):${branch#refs/heads/}" else # In detached head state, use commit instead # No escape needed From e2fbfa6c736a087bc5ad17e3dc7bc9e0e1f157e5 Mon Sep 17 00:00:00 2001 From: Darren Bishop Date: Mon, 28 Nov 2022 15:03:50 +0000 Subject: [PATCH 2/5] Update liquidprompt.theme.bash --- themes/liquidprompt/liquidprompt.theme.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/liquidprompt/liquidprompt.theme.bash b/themes/liquidprompt/liquidprompt.theme.bash index c458ad4a..ebf55969 100644 --- a/themes/liquidprompt/liquidprompt.theme.bash +++ b/themes/liquidprompt/liquidprompt.theme.bash @@ -40,10 +40,11 @@ _lp_git_branch() # not 1.7.9 (Ubuntu 12.04) if branch="$(\git symbolic-ref -q HEAD)"; then __lp_escape "$(\git rev-parse --short=5 -q HEAD 2>/dev/null):${branch#refs/heads/}" + lp_vcs_branch="$ret" else # In detached head state, use commit instead # No escape needed - \git rev-parse --short -q HEAD 2>/dev/null + lp_vcs_branch="$(\git rev-parse --short -q HEAD 2>/dev/null)" fi } From 7724fcab6b16c63500b2748de7ba2d961405a648 Mon Sep 17 00:00:00 2001 From: Darren Bishop Date: Tue, 29 Nov 2022 08:56:31 +0000 Subject: [PATCH 3/5] Update liquidprompt.theme.bash Added `ret` to local declarations as per provided liquidprompt change notes --- themes/liquidprompt/liquidprompt.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/liquidprompt/liquidprompt.theme.bash b/themes/liquidprompt/liquidprompt.theme.bash index ebf55969..3e5ff013 100644 --- a/themes/liquidprompt/liquidprompt.theme.bash +++ b/themes/liquidprompt/liquidprompt.theme.bash @@ -35,7 +35,7 @@ _lp_git_branch() \git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return - local branch + local branch ret # Recent versions of Git support the --short option for symbolic-ref, but # not 1.7.9 (Ubuntu 12.04) if branch="$(\git symbolic-ref -q HEAD)"; then From 5e92af959abcd9bec98d7df49026ba7a2c16864d Mon Sep 17 00:00:00 2001 From: Darren Bishop Date: Tue, 29 Nov 2022 11:28:21 +0000 Subject: [PATCH 4/5] Attempt to no break existing installs --- themes/liquidprompt/liquidprompt.theme.bash | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/themes/liquidprompt/liquidprompt.theme.bash b/themes/liquidprompt/liquidprompt.theme.bash index 3e5ff013..9631cab7 100644 --- a/themes/liquidprompt/liquidprompt.theme.bash +++ b/themes/liquidprompt/liquidprompt.theme.bash @@ -21,7 +21,7 @@ export LP_BATTERY_THRESHOLD=${LP_BATTERY_THRESHOLD:-75} export LP_LOAD_THRESHOLD=${LP_LOAD_THRESHOLD:-60} export LP_TEMP_THRESHOLD=${LP_TEMP_THRESHOLD:-80} - +unset _lp_legacy _lp_escape __lp_escape source "$targetdir/liquidprompt" prompt() { true; } export PS2=" ┃ " @@ -29,23 +29,37 @@ export LP_PS1_PREFIX="┌─" export LP_PS1_POSTFIX="\n└▪ " export LP_ENABLE_RUNTIME=0 +_lp_legacy() +{ + type -t _lp_escape &> /dev/null +} + +_lp_legacy && __lp_escape() +{ + ret="$(_lp_escape "$@")" +} + _lp_git_branch() { (( LP_ENABLE_GIT )) || return \git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return - local branch ret + local commit branch ret + + commit="$(\git rev-parse --short -q HEAD 2>/dev/null)" + # Recent versions of Git support the --short option for symbolic-ref, but # not 1.7.9 (Ubuntu 12.04) if branch="$(\git symbolic-ref -q HEAD)"; then - __lp_escape "$(\git rev-parse --short=5 -q HEAD 2>/dev/null):${branch#refs/heads/}" + __lp_escape "$commit:${branch#refs/heads/}" lp_vcs_branch="$ret" else # In detached head state, use commit instead # No escape needed - lp_vcs_branch="$(\git rev-parse --short -q HEAD 2>/dev/null)" + lp_vcs_branch="$commit" fi + _lp_legacy && echo $lp_vcs_branch || return 0 } _lp_time() { From d7b6cff2c1d4beedef7340f6e295d786a6635d20 Mon Sep 17 00:00:00 2001 From: Darren Bishop Date: Tue, 29 Nov 2022 11:54:24 +0000 Subject: [PATCH 5/5] Removed trailing whitespace on line 51 --- themes/liquidprompt/liquidprompt.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/liquidprompt/liquidprompt.theme.bash b/themes/liquidprompt/liquidprompt.theme.bash index 9631cab7..17458fd5 100644 --- a/themes/liquidprompt/liquidprompt.theme.bash +++ b/themes/liquidprompt/liquidprompt.theme.bash @@ -48,7 +48,7 @@ _lp_git_branch() local commit branch ret commit="$(\git rev-parse --short -q HEAD 2>/dev/null)" - + # Recent versions of Git support the --short option for symbolic-ref, but # not 1.7.9 (Ubuntu 12.04) if branch="$(\git symbolic-ref -q HEAD)"; then