Skip to content

Instantly share code, notes, and snippets.

@fionn
Created July 15, 2022 12:02
Show Gist options
  • Save fionn/6d362f464d6aa6396621ca8b6c8117dc to your computer and use it in GitHub Desktop.
Save fionn/6d362f464d6aa6396621ca8b6c8117dc to your computer and use it in GitHub Desktop.
Remove Vim undo files when the target doesn't exist anymore
#!/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