1 files changed, 14 insertions, 0 deletions
diff --git a/session.bash b/session.bash
index 990966b..35eb7de 100644
--- a/session.bash
+++ b/session.bash
@@ -53,6 +53,20 @@ session() {
false
fi
}
+
+# NOHIST handling - clear history on session exit
+# FIXME: what happens if another plugin wants to hook EXIT?! (they get replaced/overridden - this could be a problem)
+trap '
+ if [[ "${HISTFILE#~/.bash_history.}" != "$HISTFILE" ]]; then
+ session="${HISTFILE#~/.bash_history.}"
+ sessioncwd="$(grep -s '\'' # '\''"$session"'\''$'\'' ~/.bash_session_cwd | tail -n 1)"
+ sessionflags="${sessioncwd% # *}"
+ sessionflags="${sessionflags##* # }"
+ if (eval "$sessionflags" && test -v NOHIST); then
+ history -c
+ fi
+ fi
+' exit
# setup completion for session(), using only builtins
complete -C 'source <(printf "%s" '\''
set -- ~/.bash_history."$2"*
|