From f4a32f1a69cc42926b0b592104f007a2b1153b7a Mon Sep 17 00:00:00 2001 From: "Andrew R. M" Date: Fri, 4 Apr 2025 17:43:05 +0000 Subject: [PATCH] Ensure persistent history exists --- bash/.bashrc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bash/.bashrc b/bash/.bashrc index 15b6b68..0d486a8 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -64,6 +64,10 @@ log_bash_persistent_history() ]] local date_part="${BASH_REMATCH[1]}" local command_part="${BASH_REMATCH[2]}" + # Ensure file exists + if ! [ -w "$(dirname ${PERSISTENT_HISTFILE})" ]; then + mkdir -p $(dirname ${PERSISTENT_HISTFILE}) + fi if [ "$command_part" != "$PERSISTENT_HISTORY_LAST" ] then echo $date_part "|" "$rc" "|" "$command_part" >> "${PERSISTENT_HISTFILE}"