Skip to content

Commit

Permalink
theme/codeword: adopt automatic history
Browse files Browse the repository at this point in the history
Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature.
  • Loading branch information
gaelicWizard committed Jan 1, 2022
1 parent bc8a3cd commit 34c9d79
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion themes/codeword/codeword.theme.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# 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_PREFIX="${SCM_THEME_PROMPT_SUFFIX:-}"
SCM_THEME_PROMPT_DIRTY="${bold_red?}${normal?}"
SCM_THEME_PROMPT_CLEAN="${bold_green?}${normal?}"
Expand All @@ -21,5 +33,4 @@ function prompt() {
PS1="$(user_host_path_prompt)$(virtualenv_prompt)$(scm_prompt) $(mark_prompt) "
}

safe_append_prompt_command '_save-and-reload-history 1'
safe_append_prompt_command prompt

0 comments on commit 34c9d79

Please sign in to comment.