From 37ed2cbaf7a321c2fa8a0e14d460907ee2db41c6 Mon Sep 17 00:00:00 2001 From: tdro Date: Tue, 5 Jul 2022 04:53:10 -0400 Subject: .local/bin/bashhistory: Create append only backup --- .local/bin/bashhistory | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.local/bin/bashhistory b/.local/bin/bashhistory index 6320834..47eb762 100755 --- a/.local/bin/bashhistory +++ b/.local/bin/bashhistory @@ -11,9 +11,6 @@ _prune() { sort --unique "$1" | sponge "$1" # Remove all duplicate entries. } -mkdir --parents "$directory" -touch "$current" - _migrate() { [ -f "$default" ] && cat "$default" >>"$persist" && @@ -23,9 +20,13 @@ _migrate() { _store() { cat "$current" >> "$persist" && + cat "$current" >> "$persist.bak" && _prune "$persist" && true > "$current" } +mkdir --parents "$directory" +touch "$current" + _migrate || true _store -- cgit v1.2.3