aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2021-08-28 04:30:37 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2021-08-28 04:30:37 +0200
commitaa8ef4e7c49c8ebe8c6b3c51610e797288413139 (patch)
treef05017d3d3bb31e1fa4835a88f12bd0d8912b388 /bash
parent529ca16719951350ad0c9283dbaf41305c2d7ded (diff)
downloaddotfiles-aa8ef4e7c49c8ebe8c6b3c51610e797288413139.tar.gz
bashboard
Diffstat (limited to 'bash')
-rw-r--r--bash/board.bash14
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