Skip to content

Commit 569b8b8

Browse files
committed
theme/nwinkler: adopt automatic history
Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature.
1 parent 7823e36 commit 569b8b8

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

themes/nwinkler/nwinkler.theme.bash

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616
# since 'fasd' is messing with the $PROMPT_COMMAND
1717

1818

19+
case $HISTCONTROL in
20+
*'auto'*)
21+
: # Do nothing, already configured.
22+
;;
23+
*)
24+
# Append new history lines to history file
25+
HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave"
26+
;;
27+
esac
28+
safe_append_preexec '_bash-it-history-auto-load'
29+
safe_append_prompt_command '_bash-it-history-auto-save'
30+
1931
PROMPT_END_CLEAN="${green}${reset_color}"
2032
PROMPT_END_DIRTY="${red}${reset_color}"
2133

@@ -28,8 +40,6 @@ prompt_setter() {
2840
if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN
2941
else PROMPT_END=$PROMPT_END_DIRTY
3042
fi
31-
# Save history
32-
_save-and-reload-history 1
3343
PS1="($(clock_prompt)) $(scm_char) [${blue}\u${reset_color}@${green}\H${reset_color}] ${yellow}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) "
3444
PS2='> '
3545
PS4='+ '

themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,23 @@ prompt_setter() {
9595
if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN
9696
else PROMPT_END=$PROMPT_END_DIRTY
9797
fi
98-
# Save history
99-
_save-and-reload-history 1
10098
PS1="($(clock_prompt)${reset_color}) $(scm_char) [${USERNAME_COLOR}\u${reset_color}@${HOSTNAME_COLOR}\H${reset_color}] ${PATH_COLOR}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) "
10199
PS2='> '
102100
PS4='+ '
103101
}
104102

103+
case $HISTCONTROL in
104+
*'auto'*)
105+
: # Do nothing, already configured.
106+
;;
107+
*)
108+
# Append new history lines to history file
109+
HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave"
110+
;;
111+
esac
112+
safe_append_preexec '_bash-it-history-auto-load'
113+
safe_append_prompt_command '_bash-it-history-auto-save'
114+
105115
safe_append_prompt_command prompt_setter
106116

107117
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"

0 commit comments

Comments
 (0)