Skip to content

Commit d698955

Browse files
committed
theme/codeword: adopt automatic history
Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature.
1 parent 8a3f7d4 commit d698955

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

themes/codeword/codeword.theme.bash

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# shellcheck shell=bash
22

3+
case $HISTCONTROL in
4+
*'auto'*)
5+
: # Do nothing, already configured.
6+
;;
7+
*)
8+
# Append new history lines to history file
9+
HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave"
10+
;;
11+
esac
12+
safe_append_preexec '_bash-it-history-auto-load'
13+
safe_append_prompt_command '_bash-it-history-auto-save'
14+
315
SCM_THEME_PROMPT_PREFIX="${SCM_THEME_PROMPT_SUFFIX:-}"
416
SCM_THEME_PROMPT_DIRTY="${bold_red?}${normal?}"
517
SCM_THEME_PROMPT_CLEAN="${bold_green?}${normal?}"
@@ -21,5 +33,4 @@ function prompt() {
2133
PS1="$(user_host_path_prompt)$(virtualenv_prompt)$(scm_prompt) $(mark_prompt) "
2234
}
2335

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

0 commit comments

Comments
 (0)