Created
July 15, 2022 12:02
-
-
Save fionn/6d362f464d6aa6396621ca8b6c8117dc to your computer and use it in GitHub Desktop.
Remove Vim undo files when the target doesn't exist anymore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
undodir=${XDG_CACHE_HOME:-$HOME/.cache}/vim/undo/ | |
pushd "$undodir" >/dev/null | |
for undo_file in *; do | |
real_file=${undo_file//%/\/} | |
[[ -f "$real_file" ]] || rm -v -- "$undo_file" | |
done | |
popd >/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment