theme/doubletime: 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:56:20 -07:00 committed by John D Pell
parent 569b8b8c46
commit db04b2b29f
3 changed files with 36 additions and 6 deletions

View File

@ -1,5 +1,17 @@
# shellcheck shell=bash # shellcheck shell=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'
SCM_THEME_PROMPT_DIRTY='' SCM_THEME_PROMPT_DIRTY=''
SCM_THEME_PROMPT_CLEAN='' SCM_THEME_PROMPT_CLEAN=''
SCM_GIT_CHAR="${bold_cyan}±${normal}" SCM_GIT_CHAR="${bold_cyan}±${normal}"
@ -29,8 +41,6 @@ else
fi fi
function prompt_setter() { function prompt_setter() {
# Save history
_save-and-reload-history 1
PS1=" PS1="
$(clock_prompt) $(scm_char) [${THEME_PROMPT_HOST_COLOR}\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)\w $(clock_prompt) $(scm_char) [${THEME_PROMPT_HOST_COLOR}\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)\w
$(scm_prompt)$reset_color $ " $(scm_prompt)$reset_color $ "

View File

@ -2,9 +2,19 @@
source "$BASH_IT/themes/doubletime/doubletime.theme.bash" source "$BASH_IT/themes/doubletime/doubletime.theme.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 prompt_setter() { function prompt_setter() {
# Save history
_save-and-reload-history 1
PS1=" PS1="
$(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt) $(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)
\w \w

View File

@ -2,9 +2,19 @@
source "$BASH_IT/themes/doubletime/doubletime.theme.bash" source "$BASH_IT/themes/doubletime/doubletime.theme.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 prompt_setter() { function prompt_setter() {
# Save history
_save-and-reload-history 1
PS1=" PS1="
$(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt) $(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)
\w \w