From d9b29b3409c81294ba4812ad8574f926683e45ae Mon Sep 17 00:00:00 2001 From: John D Pell Date: Fri, 10 Sep 2021 13:38:35 -0700 Subject: [PATCH 1/9] themes: use `_bash_it_history_auto_save()` First pass to use _Bash It_'s automatic history management. --- themes/barbuk/barbuk.theme.bash | 2 +- themes/font/font.theme.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 themes/font/font.theme.bash diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index b614d148..27c3861e 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -80,7 +80,7 @@ function _prompt { _exit-code exit_code _git-uptream-remote-logo - history -a + HISTCONTROL="${HISTCONTROL:-}:autosave" _bash_it_history_auto_save # Detect root shell if [ "$(whoami)" = root ]; then diff --git a/themes/font/font.theme.bash b/themes/font/font.theme.bash old mode 100644 new mode 100755 index 2dbcccea..ca558c9f --- a/themes/font/font.theme.bash +++ b/themes/font/font.theme.bash @@ -56,7 +56,7 @@ function prompt_command() { fi # Append new history lines to history file - history -a + HISTCONTROL="${HISTCONTROL:-}:autosave" _bash_it_history_auto_save PS1="$(clock_prompt)${virtualenv}$(user_host_prompt)${bold_cyan}\W $(scm_prompt_char_info)${ret_status}→ ${normal}" } From 0758b861938cac35668b5fd06ab0d5e6397fcdb3 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Fri, 10 Sep 2021 13:45:43 -0700 Subject: [PATCH 2/9] themes/font: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/font/font.theme.bash | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) mode change 100755 => 100644 themes/font/font.theme.bash diff --git a/themes/font/font.theme.bash b/themes/font/font.theme.bash old mode 100755 new mode 100644 index ca558c9f..d611745b --- a/themes/font/font.theme.bash +++ b/themes/font/font.theme.bash @@ -41,6 +41,16 @@ USER_HOST_THEME_PROMPT_SUFFIX=" " VIRTUALENV_THEME_PROMPT_PREFIX='(' VIRTUALENV_THEME_PROMPT_SUFFIX=') ' +case $HISTCONTROL in +*'auto'*) + : # Do nothing, already configured. + ;; +*) + # Append new history lines to history file + HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave" + ;; +esac + function prompt_command() { # This needs to be first to save last command return code local RC="$?" @@ -55,10 +65,8 @@ function prompt_command() { ret_status="${bold_red}" fi - # Append new history lines to history file - HISTCONTROL="${HISTCONTROL:-}:autosave" _bash_it_history_auto_save - PS1="$(clock_prompt)${virtualenv}$(user_host_prompt)${bold_cyan}\W $(scm_prompt_char_info)${ret_status}→ ${normal}" } +save_append_preexec _bash-it-history-auto-save safe_append_prompt_command prompt_command From a8f2dc53d1aab30059ca68c83f6fc869c1deeec2 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Fri, 10 Sep 2021 13:46:03 -0700 Subject: [PATCH 3/9] theme/barbuk: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/barbuk/barbuk.theme.bash | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index 27c3861e..71712de9 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -41,6 +41,16 @@ SCM_THEME_BRANCH_TRACK_PREFIX="${normal} ⤏ ${cyan}" SCM_THEME_CURRENT_USER_PREFFIX='  ' SCM_GIT_SHOW_CURRENT_USER=false +case $HISTCONTROL in + *'auto'*) + : # Do nothing, already configured. + ;; + *) + # Append new history lines to history file + HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave" + ;; +esac + function _git-uptream-remote-logo { [[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" @@ -80,8 +90,6 @@ function _prompt { _exit-code exit_code _git-uptream-remote-logo - HISTCONTROL="${HISTCONTROL:-}:autosave" _bash_it_history_auto_save - # Detect root shell if [ "$(whoami)" = root ]; then dir_color=$red @@ -109,4 +117,5 @@ function _prompt { PS1="${PS1}${wrap_char}❯${normal} " } +safe_append_preexec _bash-it-history-auto-save safe_append_prompt_command _prompt From 8a3cc89bf208407f9cf55e1c268db1318daf03da Mon Sep 17 00:00:00 2001 From: John D Pell Date: Fri, 10 Sep 2021 13:55:05 -0700 Subject: [PATCH 4/9] theme/rainbobrite: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/rainbowbrite/rainbowbrite.theme.bash | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/themes/rainbowbrite/rainbowbrite.theme.bash b/themes/rainbowbrite/rainbowbrite.theme.bash index 07e5843f..826baf00 100644 --- a/themes/rainbowbrite/rainbowbrite.theme.bash +++ b/themes/rainbowbrite/rainbowbrite.theme.bash @@ -5,9 +5,19 @@ # ± ~/path/to (branch ✓) $ # in glorious red / blue / yellow color scheme +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' + prompt_setter() { - # Save history - _save-and-reload-history 1 # displays user@server in purple # PS1="$red$(scm_char) $purple\u@\h$reset_color:$blue\w$yellow$(scm_prompt_info)$(ruby_version_prompt) $black\$$reset_color " # no user@server From 24a4067cb32701fbb706786dafed0e7edc5a01fe Mon Sep 17 00:00:00 2001 From: John D Pell Date: Fri, 10 Sep 2021 13:55:23 -0700 Subject: [PATCH 5/9] theme/powerline-plain: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/powerline-plain/powerline-plain.base.bash | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/themes/powerline-plain/powerline-plain.base.bash b/themes/powerline-plain/powerline-plain.base.bash index ce91ef89..60aa27ae 100644 --- a/themes/powerline-plain/powerline-plain.base.bash +++ b/themes/powerline-plain/powerline-plain.base.bash @@ -1,5 +1,18 @@ +# shellcheck shell=bash . "$BASH_IT/themes/powerline/powerline.base.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 __powerline_left_segment { local OLD_IFS="${IFS}"; IFS="|" local params=( $1 ) @@ -34,8 +47,6 @@ function __powerline_prompt_command { LAST_SEGMENT_COLOR="" PROMPT_AFTER="${POWERLINE_PROMPT_AFTER}" - _save-and-reload-history "${HISTORY_AUTOSAVE:-0}" - ## left prompt ## for segment in $POWERLINE_PROMPT; do local info="$(__powerline_${segment}_prompt)" From 7823e36d1553f3c727c6847161a323f21326d142 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Mon, 24 Jan 2022 21:39:17 -0800 Subject: [PATCH 6/9] theme/pete: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/pete/pete.theme.bash | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/themes/pete/pete.theme.bash b/themes/pete/pete.theme.bash index e55ad6eb..85947d56 100644 --- a/themes/pete/pete.theme.bash +++ b/themes/pete/pete.theme.bash @@ -7,12 +7,20 @@ function prompt_setter() { scm_char="$(scm_char)" scm_prompt_info="$(scm_prompt_info)" ruby_version_prompt="$(ruby_version_prompt)" - _save-and-reload-history 1 # Save history PS1="(${clock_prompt}) ${scm_char} [${blue?}\u${reset_color?}@${green?}\H${reset_color?}] ${yellow?}\w${reset_color?}${scm_prompt_info}${ruby_version_prompt} ${reset_color?} " PS2='> ' PS4='+ ' } +case $HISTCONTROL in + *'auto'*) + : # Do nothing, already configured. + ;; + *) + # Append new history lines to history file + HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave" + ;; +esac safe_append_prompt_command prompt_setter SCM_THEME_PROMPT_DIRTY=" ✗" From 569b8b8c46005aaa260427e720275062dbb8895c Mon Sep 17 00:00:00 2001 From: John D Pell Date: Fri, 10 Sep 2021 13:55:50 -0700 Subject: [PATCH 7/9] theme/nwinkler: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/nwinkler/nwinkler.theme.bash | 14 ++++++++++++-- .../nwinkler_random_colors.theme.bash | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/themes/nwinkler/nwinkler.theme.bash b/themes/nwinkler/nwinkler.theme.bash index 983c8d00..2f424f6c 100644 --- a/themes/nwinkler/nwinkler.theme.bash +++ b/themes/nwinkler/nwinkler.theme.bash @@ -16,6 +16,18 @@ # since 'fasd' is messing with the $PROMPT_COMMAND +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' + PROMPT_END_CLEAN="${green}→${reset_color}" PROMPT_END_DIRTY="${red}→${reset_color}" @@ -28,8 +40,6 @@ prompt_setter() { if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN else PROMPT_END=$PROMPT_END_DIRTY fi - # Save history - _save-and-reload-history 1 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) " PS2='> ' PS4='+ ' diff --git a/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash b/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash index 05391b0b..16c79448 100644 --- a/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash +++ b/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash @@ -95,13 +95,23 @@ prompt_setter() { if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN else PROMPT_END=$PROMPT_END_DIRTY fi - # Save history - _save-and-reload-history 1 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) " PS2='> ' PS4='+ ' } +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' + safe_append_prompt_command prompt_setter SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" From db04b2b29f74eb3bbbcc14f8c2d2d4ed6ad0a885 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Fri, 10 Sep 2021 13:56:20 -0700 Subject: [PATCH 8/9] theme/doubletime: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/doubletime/doubletime.theme.bash | 14 ++++++++++++-- .../doubletime_multiline.theme.bash | 14 ++++++++++++-- .../doubletime_multiline_pyonly.theme.bash | 14 ++++++++++++-- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/themes/doubletime/doubletime.theme.bash b/themes/doubletime/doubletime.theme.bash index 8186db73..536573e4 100644 --- a/themes/doubletime/doubletime.theme.bash +++ b/themes/doubletime/doubletime.theme.bash @@ -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}" @@ -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 $ " diff --git a/themes/doubletime_multiline/doubletime_multiline.theme.bash b/themes/doubletime_multiline/doubletime_multiline.theme.bash index f2dfe43a..8b2bab04 100644 --- a/themes/doubletime_multiline/doubletime_multiline.theme.bash +++ b/themes/doubletime_multiline/doubletime_multiline.theme.bash @@ -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 diff --git a/themes/doubletime_multiline_pyonly/doubletime_multiline_pyonly.theme.bash b/themes/doubletime_multiline_pyonly/doubletime_multiline_pyonly.theme.bash index 0fe0eff4..a2a5884c 100644 --- a/themes/doubletime_multiline_pyonly/doubletime_multiline_pyonly.theme.bash +++ b/themes/doubletime_multiline_pyonly/doubletime_multiline_pyonly.theme.bash @@ -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 From ee65fd87bf6c535ed59ba7e85e871d9931f9f74b Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 1 Jan 2022 14:55:24 -0800 Subject: [PATCH 9/9] theme/codeword: adopt automatic history Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature. --- themes/codeword/codeword.theme.bash | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/themes/codeword/codeword.theme.bash b/themes/codeword/codeword.theme.bash index d52403c1..16f10987 100644 --- a/themes/codeword/codeword.theme.bash +++ b/themes/codeword/codeword.theme.bash @@ -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_PREFIX="${SCM_THEME_PROMPT_SUFFIX:-}" SCM_THEME_PROMPT_DIRTY="${bold_red?} ✗${normal?}" SCM_THEME_PROMPT_CLEAN="${bold_green?} ✓${normal?}" @@ -21,5 +33,4 @@ function prompt() { PS1="$(user_host_path_prompt)$(virtualenv_prompt)$(scm_prompt) $(mark_prompt) " } -safe_append_prompt_command '_save-and-reload-history 1' safe_append_prompt_command prompt