bonfire/config/zsh/.zshenv

35 lines
834 B
Plaintext
Raw Normal View History

2023-06-06 23:18:09 +05:00
function _cache {
2023-06-15 11:05:31 +05:00
(( $+commands[$1] )) || return 1
local cache_dir="$XDG_CACHE_HOME/${SHELL##*/}"
local cache="$cache_dir/$1"
if [[ ! -f $cache || ! -s $cache ]]; then
echo "Caching $1"
mkdir -p $cache_dir
"$@" >$cache
chmod 600 $cache
fi
if [[ -o interactive ]]; then
source $cache || rm -f $cache
fi
2023-06-06 23:18:09 +05:00
}
function _source {
2023-06-15 11:05:31 +05:00
for file in "$@"; do
[ -r $file ] && source $file
done
2023-06-06 23:18:09 +05:00
}
# Be more restrictive with permissions; no one has any business reading things
# that don't belong to them.
if (( EUID != 0 )); then
2023-06-15 11:05:31 +05:00
umask 027
2023-06-06 23:18:09 +05:00
else
# Be even less permissive if root.
2023-06-15 11:05:31 +05:00
umask 077
2023-06-06 23:18:09 +05:00
fi
# Auto-generated by my nix config
_source ${0:a:h}/extra.zshenv
# If you have host-local configuration, this is where you'd put it
_source $ZDOTDIR/local.zshenv