summaryrefslogtreecommitdiff
path: root/.local/bin/previewclean
blob: 8b0a570d13eac7592869e8f137b686ce31a59d4d (plain)
1
2
3
4
5
6
7
8
9
10
#!/bin/sh

threshold="200000" # 200 MB
previewdir="${XDG_CACHE_HOME:-$HOME/.cache}/lf"

# Check if the total size of the preview directory exceeds the threshold
# and remove the last viewed file until it doesn't
while [ "$(du -s "$previewdir" | cut -f1)" -gt "$threshold" ]; do
	rm -f "$(find "$previewdir" -type f -printf '%T+ %p\n' | sort | head -n1 | cut -d' ' -f2)"
done