diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2021-08-28 04:30:37 +0200 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2021-08-28 04:30:37 +0200 |
commit | aa8ef4e7c49c8ebe8c6b3c51610e797288413139 (patch) | |
tree | f05017d3d3bb31e1fa4835a88f12bd0d8912b388 | |
parent | 529ca16719951350ad0c9283dbaf41305c2d7ded (diff) | |
download | dotfiles-aa8ef4e7c49c8ebe8c6b3c51610e797288413139.tar.gz |
bashboard
-rw-r--r-- | bash/board.bash | 14 |
1 files 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 |