themes/font: adopt automatic history
Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature.pull/1951/head
parent
d9b29b3409
commit
0758b86193
|
|
@ -41,6 +41,16 @@ USER_HOST_THEME_PROMPT_SUFFIX=" "
|
||||||
VIRTUALENV_THEME_PROMPT_PREFIX='('
|
VIRTUALENV_THEME_PROMPT_PREFIX='('
|
||||||
VIRTUALENV_THEME_PROMPT_SUFFIX=') '
|
VIRTUALENV_THEME_PROMPT_SUFFIX=') '
|
||||||
|
|
||||||
|
case $HISTCONTROL in
|
||||||
|
*'auto'*)
|
||||||
|
: # Do nothing, already configured.
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Append new history lines to history file
|
||||||
|
HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
function prompt_command() {
|
function prompt_command() {
|
||||||
# This needs to be first to save last command return code
|
# This needs to be first to save last command return code
|
||||||
local RC="$?"
|
local RC="$?"
|
||||||
|
|
@ -55,10 +65,8 @@ function prompt_command() {
|
||||||
ret_status="${bold_red}"
|
ret_status="${bold_red}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Append new history lines to history file
|
|
||||||
HISTCONTROL="${HISTCONTROL:-}:autosave" _bash_it_history_auto_save
|
|
||||||
|
|
||||||
PS1="$(clock_prompt)${virtualenv}$(user_host_prompt)${bold_cyan}\W $(scm_prompt_char_info)${ret_status}→ ${normal}"
|
PS1="$(clock_prompt)${virtualenv}$(user_host_prompt)${bold_cyan}\W $(scm_prompt_char_info)${ret_status}→ ${normal}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
save_append_preexec _bash-it-history-auto-save
|
||||||
safe_append_prompt_command prompt_command
|
safe_append_prompt_command prompt_command
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue