From aa8ef4e7c49c8ebe8c6b3c51610e797288413139 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Sat, 28 Aug 2021 04:30:37 +0200 Subject: bashboard --- bash/board.bash | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bash/board.bash b/bash/board.bash index 7301741..265255a 100644 --- a/bash/board.bash +++ b/bash/board.bash @@ -3,11 +3,12 @@ BB_HIST_DIR="$HOME/.cache/bashboard/" BB_SHORTCUT=() BB_LIST_LEN=5 +BB_PRUNE_DAYS=5 [ ! -d "$BB_HIST_DIR" ] && mkdir -p "$BB_HIST_DIR" # format -# NUM YYYY-MM-DD PATH +# NUM EPOCH PATH # add ssh targets @@ -69,7 +70,16 @@ function bb_prune { # Older than... # Folder exists? # shorten list - return 1 + local COUNT FILEDATE FILEPATH COMP + COMP=$(date -d "-${BB_PRUNE_DAYS}days" +%s) + + echo -n > "$BB_HIST_DIR/history.new" + + while read -r COUNT FILEDATE FILEPATH; do + [ $FILEDATE -ge $COMP ] && echo "$COUNT $FILEDATE $FILEPATH" >> "$BB_HIST_DIR/history.new" + done < "$BB_HIST_DIR/history" + + mv "$BB_HIST_DIR/history.new" "$BB_HIST_DIR/history" } bashboard -- cgit v1.2.3