Skip to content

Commit 463686f

Browse files
committed
theme/liquidprompt: don’t clobber bash-preexec
Alsö, install default configuration file
1 parent 11091c6 commit 463686f

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

themes/liquidprompt/liquidprompt.theme.bash

+20-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ __bash_it_theme_liquidprompt_path="github.com/nojhan/liquidprompt"
99
__bash_it_theme_liquidprompt_dir="${BASH_IT?}/vendor/${__bash_it_theme_liquidprompt_path}"
1010
if [[ ! -d "${__bash_it_theme_liquidprompt_dir}" ]]; then
1111
if git clone --branch stable "https://${__bash_it_theme_liquidprompt_path}" "${__bash_it_theme_liquidprompt_dir}";then
12-
echo -e "Successfully cloned liquidprompt!\n More configuration in '${__bash_it_theme_liquidprompt_dir/$HOME/\~}/liquid.theme'."
12+
__bash_it_theme_liquidprompt_lqprc="${XDG_CONFIG_HOME:-"$HOME/.config"}/liquidpromptrc"
13+
__bash_it_theme_liquidprompt_tilde='~'
14+
if [[ ! -e "${__bash_it_theme_liquidprompt_lqprc}" ]]; then
15+
sed -e 's/^LP_/#LP_/g' -e 's;#LOCAL_RCFILE=$HOME/.liquidpromptrc.local;LOCAL_RCFILE=${BASH_SOURCE[0]}.local;g' -e 's/#\[ -f "$LOCAL_RCFILE" \] && source "$LOCAL_RCFILE"/if [[ -s $LOCAL_RCFILE ]]; then\'$'\n\t''source "$LOCAL_RCFILE"\'$'\n''fi/g' < "${__bash_it_theme_liquidprompt_dir}/liquidpromptrc-dist" > "${__bash_it_theme_liquidprompt_lqprc}"
16+
fi
17+
echo -e "Successfully cloned liquidprompt!\n More configuration in '${__bash_it_theme_liquidprompt_lqprc//$HOME/$__bash_it_theme_liquidprompt_tilde}' (or '${__bash_it_theme_liquidprompt_lqprc//$HOME/$__bash_it_theme_liquidprompt_tilde}.local')."
1318
fi
1419
fi
1520

@@ -22,9 +27,19 @@ LP_MARK_LOAD="📈 "
2227
: "${LP_LOAD_THRESHOLD:=60}"
2328
: "${LP_TEMP_THRESHOLD:=80}"
2429

25-
## Load theme
30+
## Load theme, but don't activate
2631
# shellcheck source-path=SCRIPTDIR/../../vendor/github.com/nojhan/liquidprompt
27-
source "${__bash_it_theme_liquidprompt_dir}/liquidprompt"
32+
source "${__bash_it_theme_liquidprompt_dir}/liquidprompt" --no-activate
33+
34+
## Activate theme, without clobbering `bash-preexec`
35+
LP_OLD_PS1="${PROMPT:-${PS1:-\$ }}"
36+
LP_OLD_PROMPT_COMMAND=""
37+
function prompt_on() { :; }
38+
function prompt_off() { :; }
39+
function prompt_OFF() { :; }
40+
TERM_PROGRAM=not_apple_terminal LP_ENABLE_RUNTIME=0 LP_ENABLE_RUNTIME_BELL=0 lp_activate
41+
safe_append_preexec '__lp_runtime_before'
42+
safe_append_prompt_command '__lp_set_prompt'
2843

2944
## Override upstream defaults
3045
PS2=""
@@ -74,3 +89,5 @@ function _lp_temp_acpi() {
7489
((i > ${temperature:-0})) && ((i != 127)) && temperature=i
7590
done
7691
}
92+
93+
unset "${!__bash_it_theme_liquidprompt_@}"

0 commit comments

Comments
 (0)