From 0758b861938cac35668b5fd06ab0d5e6397fcdb3 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Fri, 10 Sep 2021 13:45:43 -0700 Subject: [PATCH] themes/font: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/font/font.theme.bash | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) mode change 100755 => 100644 themes/font/font.theme.bash diff --git a/themes/font/font.theme.bash b/themes/font/font.theme.bash old mode 100755 new mode 100644 index ca558c9f..d611745b --- a/themes/font/font.theme.bash +++ b/themes/font/font.theme.bash @@ -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