X-Git-Url: https://git.ganneff.de//index.cgi?p=zsh.git;a=blobdiff_plain;f=.zsh%2Fzshenv.home;h=1ed87a047821bf3afe0b4d2b88349999b0c3efec;hp=5f79ff393322ce6f800f65dfce05cef782e623ca;hb=bc46f60ea0d6bc1116e2c667b0af9e5c877622b9;hpb=8e6151b3e52cdff56bdb1b8debca358669c96e06;ds=sidebyside diff --git a/.zsh/zshenv.home b/.zsh/zshenv.home index 5f79ff3..1ed87a0 100644 --- a/.zsh/zshenv.home +++ b/.zsh/zshenv.home @@ -5,8 +5,26 @@ # Written by Joerg Jaspert # ############ -ZDOTDIR=${ZDOTDIR:-"${HOME}/.zsh"} -[ -r "${ZDOTDIR}/zshenv" ] && . "${ZDOTDIR}/zshenv" +# This assumes that $HOME/.zshenv is a symlink to +# $ZDOTDIR/zshenv.home (as is my default). +if zp=$(readlink -f ${HOME}/.zshenv 2>/dev/null); then + zp=${zp%/*} +elif zp=$(greadlink -f ${HOME}/.zshenv 2>/dev/null); then + # MacOS readlink isn't up to the task, user needs to + # install the gnu coreutils for it + zp=${zp%/*} +else + # If both fail, use the "traditional" way of hardcoding + zp="${HOME}/.zsh" +fi +ZDOTDIR=${ZDOTDIR:-$zp} +# In case the user did not symlink us, but copy, we fallback to +# the traditional way too. +if [[ ${HOME} == ${ZDOTDIR} ]]; then + ZDOTDIR="${HOME}/.zsh" +fi + +[ -r "${ZDOTDIR}/zshenv" ] && source "${ZDOTDIR}/zshenv" # If you want to "profile" the shell initialization, enable # the following lines. @@ -23,5 +41,9 @@ ZDOTDIR=${ZDOTDIR:-"${HOME}/.zsh"} ## set options to turn on tracing and expansion of commands contained in the prompt #setopt xtrace prompt_subst +# Store "starttime" of shell in case user wants to see how long loading took +_start_time=$(( $(( $(date +%s) * 1000000000 )) + $(date +%N) )) +# Variable is removed on end of shell load + # Don't do anything more in here, do everything inside # $ZDOTDIR!