Readable direnv cache directories

This commit is contained in:
Ceferino Patino 2024-08-25 11:48:47 -05:00
commit dbae5eb0b3
No known key found for this signature in database

View file

@ -1,8 +1,10 @@
: ${XDG_CACHE_HOME:=$HOME/.cache}
declare -A direnv_layout_dirs
direnv_layout_dir() {
local hash path
echo "${direnv_layout_dirs[$PWD]:=$(
echo -n "$XDG_CACHE_HOME"/direnv/layouts/
echo -n "$PWD" | sha1sum | cut -d ' ' -f 1
hash="$(sha1sum - <<< "$PWD" | head -c40)"
path="${PWD//[^a-zA-Z0-9]/-}"
echo "${XDG_CACHE_HOME}/direnv/layouts/${hash}${path}"
)}"
}