zsh: host-specific caches
This commit is contained in:
parent
2150fccea7
commit
1a7ae13176
|
@ -2,10 +2,13 @@ is-callable() {
|
|||
(( $+commands[$1] )) || (( $+functions[$1] )) || (( $+aliases[$1] ))
|
||||
}
|
||||
|
||||
ZSH_CACHE_DIR="$HOME/.zsh/cache/$(hostname)"
|
||||
[[ ! -d "$ZSH_CACHE_DIR" ]] && mkdir -p "$ZSH_CACHE_DIR"
|
||||
|
||||
cache() {
|
||||
is-callable "$1" || return 1
|
||||
local cache="$HOME/.zsh/cache/$1-cache"
|
||||
if [ ! -s "$cache" ]; then
|
||||
local cache="${ZSH_CACHE_DIR}/$1-cache"
|
||||
if [[ ! -s "$cache" ]]; then
|
||||
echo "Caching $1"
|
||||
$@ >| "$cache" 2> /dev/null
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue