From b15ae7b60c3b577e0f2fdab8a9c2a3965bf21c39 Mon Sep 17 00:00:00 2001
From: John D Pell <John+git@gaelicWizard.net>
Date: Fri, 10 Sep 2021 12:50:45 -0700
Subject: [PATCH] plugins/history: Add `autoshare` to `$HISTCONTROL`

---
 plugins/available/history.plugin.bash | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/plugins/available/history.plugin.bash b/plugins/available/history.plugin.bash
index ac7dea0aee..bc6a6e2756 100644
--- a/plugins/available/history.plugin.bash
+++ b/plugins/available/history.plugin.bash
@@ -5,8 +5,13 @@ about-plugin 'improve history handling with sane defaults'
 # append to bash_history on exit.
 shopt -s histappend
 
-# erase duplicates; alternative option: HISTCONTROL=ignoredups
-: "${HISTCONTROL:=ignorespace:erasedups}"
+# 'ignorespace': don't save command lines which begin with a space to history
+# 'erasedups' (alternative 'ignoredups'): don't save duplicates to history
+# 'autoshare': automatically share history between multiple running shells
+: "${HISTCONTROL:=ignorespace:erasedups:autoshare}"
+
+safe_append_preexec '_bash_it_history_auto_save'
+safe_append_prompt_command '_bash_it_history_auto_load'
 
 # resize history to 100x the default (500)
 : "${HISTSIZE:=50000}"