Skip to content

Commit 00ed183

Browse files
authored
Merge pull request #2175 from DarrenBishop/patch-1
2 parents 662c1df + d7b6cff commit 00ed183

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

themes/liquidprompt/liquidprompt.theme.bash

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,45 @@ export LP_BATTERY_THRESHOLD=${LP_BATTERY_THRESHOLD:-75}
2121
export LP_LOAD_THRESHOLD=${LP_LOAD_THRESHOLD:-60}
2222
export LP_TEMP_THRESHOLD=${LP_TEMP_THRESHOLD:-80}
2323

24-
24+
unset _lp_legacy _lp_escape __lp_escape
2525
source "$targetdir/liquidprompt"
2626
prompt() { true; }
2727
export PS2=""
2828
export LP_PS1_PREFIX="┌─"
2929
export LP_PS1_POSTFIX="\n└▪ "
3030
export LP_ENABLE_RUNTIME=0
3131

32+
_lp_legacy()
33+
{
34+
type -t _lp_escape &> /dev/null
35+
}
36+
37+
_lp_legacy && __lp_escape()
38+
{
39+
ret="$(_lp_escape "$@")"
40+
}
41+
3242
_lp_git_branch()
3343
{
3444
(( LP_ENABLE_GIT )) || return
3545

3646
\git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return
3747

38-
local branch
48+
local commit branch ret
49+
50+
commit="$(\git rev-parse --short -q HEAD 2>/dev/null)"
51+
3952
# Recent versions of Git support the --short option for symbolic-ref, but
4053
# not 1.7.9 (Ubuntu 12.04)
4154
if branch="$(\git symbolic-ref -q HEAD)"; then
42-
_lp_escape "$(\git rev-parse --short=5 -q HEAD 2>/dev/null):${branch#refs/heads/}"
55+
__lp_escape "$commit:${branch#refs/heads/}"
56+
lp_vcs_branch="$ret"
4357
else
4458
# In detached head state, use commit instead
4559
# No escape needed
46-
\git rev-parse --short -q HEAD 2>/dev/null
60+
lp_vcs_branch="$commit"
4761
fi
62+
_lp_legacy && echo $lp_vcs_branch || return 0
4863
}
4964

5065
_lp_time() {

0 commit comments

Comments
 (0)