-# Initially based on
-# https://github.com/joshuaclayton/dotfiles/blob/master/zsh_profile.d/autoenv.zsh
-
-export AUTOENV_ENV_FILENAME=$HOME/.env_auth
-
-# Name of file to look for when entering directories.
-: ${DOTENV_FILE_ENTER:=.env}
-
-# Name of file to look for when leaving directories.
-# Requires DOTENV_HANDLE_LEAVE=1.
-: ${DOTENV_FILE_LEAVE:=.env.leave}
-
-# Look for .env in parent dirs?
-: ${DOTENV_LOOK_UPWARDS:=1}
-
-# Handle leave events when changing away from a subtree, where an "enter"
-# event was handled?
-: ${DOTENV_HANDLE_LEAVE:=1}
-
-
-# Internal: stack of entered (and handled) directories.
-_dotenv_stack_entered=()
-
-
-_dotenv_hash_pair() {
- local env_file=$1
- if (( $+2 )); then
- env_shasum=$2
- else
- env_shasum=$(shasum $env_file | cut -d' ' -f1)
- fi
- echo "$env_file:$env_shasum:1"
+: ${AUTOENV_AUTH_FILE:=~/.env_auth}
+: ${AUTOENV_FILE_ENTER:=.autoenv.zsh}
+: ${AUTOENV_FILE_LEAVE:=.autoenv_leave.zsh}
+: ${AUTOENV_LOOK_UPWARDS:=1}
+: ${AUTOENV_HANDLE_LEAVE:=1}
+: ${AUTOENV_DISABLED:=0}
+
+typeset -a _autoenv_stack_entered
+typeset -A _autoenv_stack_entered_ctime
+typeset -a _autoenv_ctime
+
+zmodload -F zsh/stat b:zstat
+_autoenv_get_file_ctime() {
+ zstat -a _autoenv_ctime +ctime $1 2>/dev/null || _autoenv_ctime=(0)