Skip to content

Instantly share code, notes, and snippets.

@justenwalker
Last active October 3, 2022 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justenwalker/fbc57f3bfda53a4fdeb3484fe7000f8f to your computer and use it in GitHub Desktop.
Save justenwalker/fbc57f3bfda53a4fdeb3484fe7000f8f to your computer and use it in GitHub Desktop.
Direnv Prune Allow List
# removes direnv allow entries which point to nonexistent .envrc files
# or where the hash of the envrc does not match
direnv_prune () {
for entry in ~/.local/share/direnv/allow/*
do
local file=$(cat $entry)
if [ ! -f $file ]
then
rm $entry
else
local hash=$( (echo $file && cat $file) | shasum -a 256 | awk '{print $1 }')
local that=$(basename $entry)
if [ ! "${hash}" = "${that}" ]
then
rm $entry
fi
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment