Skip to content

Commit 0068e38

Browse files
committed
theme/doubletime: adopt automatic history
Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature.
1 parent f9f2d16 commit 0068e38

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

themes/doubletime/doubletime.theme.bash

+12-2
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_DIRTY=''
416
SCM_THEME_PROMPT_CLEAN=''
517
SCM_GIT_CHAR="${bold_cyan}±${normal}"
@@ -29,8 +41,6 @@ else
2941
fi
3042

3143
function prompt_setter() {
32-
# Save history
33-
_save-and-reload-history 1
3444
PS1="
3545
$(clock_prompt) $(scm_char) [${THEME_PROMPT_HOST_COLOR}\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)\w
3646
$(scm_prompt)$reset_color $ "

themes/doubletime_multiline/doubletime_multiline.theme.bash

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22

33
source "$BASH_IT/themes/doubletime/doubletime.theme.bash"
44

5+
case $HISTCONTROL in
6+
*'auto'*)
7+
: # Do nothing, already configured.
8+
;;
9+
*)
10+
# Append new history lines to history file
11+
HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave"
12+
;;
13+
esac
14+
safe_append_preexec '_bash_it_history_auto_load'
15+
safe_append_prompt_command '_bash_it_history_auto_save'
16+
517
function prompt_setter() {
6-
# Save history
7-
_save-and-reload-history 1
818
PS1="
919
$(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)
1020
\w

themes/doubletime_multiline_pyonly/doubletime_multiline_pyonly.theme.bash

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22

33
source "$BASH_IT/themes/doubletime/doubletime.theme.bash"
44

5+
case $HISTCONTROL in
6+
*'auto'*)
7+
: # Do nothing, already configured.
8+
;;
9+
*)
10+
# Append new history lines to history file
11+
HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave"
12+
;;
13+
esac
14+
safe_append_preexec '_bash_it_history_auto_load'
15+
safe_append_prompt_command '_bash_it_history_auto_save'
16+
517
function prompt_setter() {
6-
# Save history
7-
_save-and-reload-history 1
818
PS1="
919
$(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)
1020
\w

0 commit comments

Comments
 (0)