Skip to content

Commit ec96c60

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

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

themes/codeword/codeword.theme.bash

Lines changed: 12 additions & 1 deletion
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)