From 24a4067cb32701fbb706786dafed0e7edc5a01fe Mon Sep 17 00:00:00 2001 From: John D Pell Date: Fri, 10 Sep 2021 13:55:23 -0700 Subject: [PATCH] theme/powerline-plain: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/powerline-plain/powerline-plain.base.bash | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/themes/powerline-plain/powerline-plain.base.bash b/themes/powerline-plain/powerline-plain.base.bash index ce91ef89..60aa27ae 100644 --- a/themes/powerline-plain/powerline-plain.base.bash +++ b/themes/powerline-plain/powerline-plain.base.bash @@ -1,5 +1,18 @@ +# shellcheck shell=bash . "$BASH_IT/themes/powerline/powerline.base.bash" +case $HISTCONTROL in +*'auto'*) + : # Do nothing, already configured. + ;; +*) + # Append new history lines to history file + HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave" + ;; +esac +safe_append_preexec '_bash-it-history-auto-load' +safe_append_prompt_command '_bash-it-history-auto-save' + function __powerline_left_segment { local OLD_IFS="${IFS}"; IFS="|" local params=( $1 ) @@ -34,8 +47,6 @@ function __powerline_prompt_command { LAST_SEGMENT_COLOR="" PROMPT_AFTER="${POWERLINE_PROMPT_AFTER}" - _save-and-reload-history "${HISTORY_AUTOSAVE:-0}" - ## left prompt ## for segment in $POWERLINE_PROMPT; do local info="$(__powerline_${segment}_prompt)"