Skip to content

Commit

Permalink
Merge pull request #4 from rocketspacer/add-hashed-command-content-to…
Browse files Browse the repository at this point in the history
…-cache-file-name

Add hashed command content to cache file name
  • Loading branch information
mroth authored May 4, 2022
2 parents dce3fd1 + 41a8fa4 commit 4c7fb8d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion evalcache.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
export ZSH_EVALCACHE_DIR=${ZSH_EVALCACHE_DIR:-"$HOME/.zsh-evalcache"}

function _evalcache () {
local cacheFile="$ZSH_EVALCACHE_DIR/init-${1##*/}.sh"
local cmdHash="nohash"

if builtin command -v md5 > /dev/null; then
cmdHash=$(echo -n "$*" | md5)
elif builtin command -v md5sum > /dev/null; then
cmdHash=$(echo -n "$*" | md5sum | cut -d' ' -f1)
fi

local cacheFile="$ZSH_EVALCACHE_DIR/init-${1##*/}-${cmdHash}.sh"

if [ "$ZSH_EVALCACHE_DISABLE" = "true" ]; then
eval "$("$@")"
Expand Down

0 comments on commit 4c7fb8d

Please sign in to comment.