themes/font: adopt automatic history

Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature.
pull/1951/head
John D Pell 2021-09-10 13:45:43 -07:00 committed by John D Pell
parent d9b29b3409
commit 0758b86193
1 changed files with 11 additions and 3 deletions

14
themes/font/font.theme.bash 100755 → 100644
View File

@ -41,6 +41,16 @@ USER_HOST_THEME_PROMPT_SUFFIX=" "
VIRTUALENV_THEME_PROMPT_PREFIX='('
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() {
# This needs to be first to save last command return code
local RC="$?"
@ -55,10 +65,8 @@ function prompt_command() {
ret_status="${bold_red}"
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}"
}
save_append_preexec _bash-it-history-auto-save
safe_append_prompt_command prompt_command