Added script for removing invalid commands from zsh history file

This commit is contained in:
2023-08-24 14:45:12 -04:00
parent 3cbea326e9
commit 9586503a99
2 changed files with 19 additions and 2 deletions
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env zsh
hist=()
while IFS= read -r line; do
if [[ $line == "./"* || $line == "/"* ]]; then
hist+=($line)
else
which $(echo $line | cut -d " " -f1) > /dev/null
[[ $? == 0 ]] && hist+=($line)
fi
done < "$XDG_CACHE_HOME"/zsh-histfile
echo -n "" > "$XDG_CACHE_HOME"/zsh-histfile
for item in "${hist[@]}"; do
echo "$item" >> "$XDG_CACHE_HOME"/zsh-histfile
done