Make histclean show changes in file size, remove itself from history

This commit is contained in:
2024-01-22 14:59:19 -05:00
parent 8dff9a5a5f
commit f30ec262ec
+7 -1
View File
@@ -1,11 +1,14 @@
#!/usr/bin/env zsh
echo 'Starting history size:'
ls -lh ~/.cache/zsh-histfile | cut -d " " -f5
hist=()
while IFS= read -r line; do
if [[ $line == "./"* || $line == "/"* ]]; then
hist+=($line)
else
elif [[ $line != "histclean" ]]; then
which $(echo $line | cut -d " " -f1) > /dev/null
[[ $? == 0 ]] && hist+=($line)
fi
@@ -15,3 +18,6 @@ echo -n "" > "$XDG_CACHE_HOME"/zsh-histfile
for item in "${hist[@]}"; do
echo "$item" >> "$XDG_CACHE_HOME"/zsh-histfile
done
echo 'Ending history size:'
ls -lh ~/.cache/zsh-histfile | cut -d " " -f5