Skip to content

Commit

Permalink
theme/doubletime: 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 28, 2022
1 parent 5b83594 commit 8a3f7d4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
14 changes: 12 additions & 2 deletions themes/doubletime/doubletime.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_DIRTY=''
SCM_THEME_PROMPT_CLEAN=''
SCM_GIT_CHAR="${bold_cyan}±${normal}"
Expand Down Expand Up @@ -29,8 +41,6 @@ else
fi

function prompt_setter() {
# Save history
_save-and-reload-history 1
PS1="
$(clock_prompt) $(scm_char) [${THEME_PROMPT_HOST_COLOR}\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)\w
$(scm_prompt)$reset_color $ "
Expand Down
14 changes: 12 additions & 2 deletions themes/doubletime_multiline/doubletime_multiline.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@

source "$BASH_IT/themes/doubletime/doubletime.theme.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'

function prompt_setter() {
# Save history
_save-and-reload-history 1
PS1="
$(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)
\w
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@

source "$BASH_IT/themes/doubletime/doubletime.theme.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'

function prompt_setter() {
# Save history
_save-and-reload-history 1
PS1="
$(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)
\w
Expand Down

0 comments on commit 8a3f7d4

Please sign in to comment.