From 7823e36d1553f3c727c6847161a323f21326d142 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Mon, 24 Jan 2022 21:39:17 -0800 Subject: [PATCH] theme/pete: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/pete/pete.theme.bash | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/themes/pete/pete.theme.bash b/themes/pete/pete.theme.bash index e55ad6eb..85947d56 100644 --- a/themes/pete/pete.theme.bash +++ b/themes/pete/pete.theme.bash @@ -7,12 +7,20 @@ function prompt_setter() { scm_char="$(scm_char)" scm_prompt_info="$(scm_prompt_info)" ruby_version_prompt="$(ruby_version_prompt)" - _save-and-reload-history 1 # Save history PS1="(${clock_prompt}) ${scm_char} [${blue?}\u${reset_color?}@${green?}\H${reset_color?}] ${yellow?}\w${reset_color?}${scm_prompt_info}${ruby_version_prompt} ${reset_color?} " PS2='> ' PS4='+ ' } +case $HISTCONTROL in + *'auto'*) + : # Do nothing, already configured. + ;; + *) + # Append new history lines to history file + HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave" + ;; +esac safe_append_prompt_command prompt_setter SCM_THEME_PROMPT_DIRTY=" ✗"