Last active
October 3, 2022 13:11
-
-
Save justenwalker/fbc57f3bfda53a4fdeb3484fe7000f8f to your computer and use it in GitHub Desktop.
Direnv Prune Allow List
This file contains hidden or 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
# 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