From a8f2dc53d1aab30059ca68c83f6fc869c1deeec2 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Fri, 10 Sep 2021 13:46:03 -0700 Subject: [PATCH] theme/barbuk: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/barbuk/barbuk.theme.bash | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index 27c3861e..71712de9 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -41,6 +41,16 @@ SCM_THEME_BRANCH_TRACK_PREFIX="${normal} ⤏ ${cyan}" SCM_THEME_CURRENT_USER_PREFFIX='  ' SCM_GIT_SHOW_CURRENT_USER=false +case $HISTCONTROL in + *'auto'*) + : # Do nothing, already configured. + ;; + *) + # Append new history lines to history file + HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave" + ;; +esac + function _git-uptream-remote-logo { [[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" @@ -80,8 +90,6 @@ function _prompt { _exit-code exit_code _git-uptream-remote-logo - HISTCONTROL="${HISTCONTROL:-}:autosave" _bash_it_history_auto_save - # Detect root shell if [ "$(whoami)" = root ]; then dir_color=$red @@ -109,4 +117,5 @@ function _prompt { PS1="${PS1}${wrap_char}❯${normal} " } +safe_append_preexec _bash-it-history-auto-save safe_append_prompt_command _prompt