From 66930d79eaf21d32124b10ecc396d9d629ffbd47 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Sun, 21 Apr 2024 11:50:22 -0300 Subject: Add session flags, history suppression --- session.bash | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/session.bash b/session.bash index 423ad85..990966b 100644 --- a/session.bash +++ b/session.bash @@ -25,9 +25,19 @@ fi # usage: session # switches HISTFILE to ~/.bash_history. session() { + local session sessioncwd sessionflags if [[ "$1" =~ ^[a-z][a-z0-9]*$ ]]; then + 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 # remove session switch from history - history -d -1 + history -d -1 >/dev/null 2>/dev/null || true # write/append history if shopt -q histappend; then history -a; else history -w; fi # clear history -- cgit 1.4.1