]> Sergey Matveev's repositories - zsh-autoenv.git/commitdiff
Add support for $AUTOENV_DISABLED, which skips the chpwd hook
authorDaniel Hahler <git@thequod.de>
Mon, 19 Jan 2015 18:01:20 +0000 (19:01 +0100)
committerDaniel Hahler <git@thequod.de>
Tue, 20 Jan 2015 10:16:22 +0000 (11:16 +0100)
autoenv.zsh

index 561a336072af656ae2fd1d8999f742b0d2a89480..d4cd642d48e397f0767b1268d501ace6156d7fbf 100644 (file)
@@ -21,6 +21,9 @@ export AUTOENV_ENV_FILENAME=$HOME/.env_auth
 # Enable debugging. Multiple levels are supported (max 2).
 : ${AUTOENV_DEBUG:=0}
 
+# (Temporarily) disable zsh-autoenv. This gets looked at in the chpwd handler.
+: ${AUTOENV_DISABLED:=0}
+
 # Public helper functions, which can be used from your .env files:
 #
 # Source the next .env file from parent directories.
@@ -267,10 +270,16 @@ _autoenv_get_file_upwards() {
 
 _autoenv_chpwd_prev_dir=$PWD
 _autoenv_chpwd_handler() {
-  local env_file="$PWD/$AUTOENV_FILE_ENTER"
-
   _autoenv_debug "Calling chpwd handler: PWD=$PWD"
 
+  if (( $AUTOENV_DISABLED )); then
+    _autoenv_debug "Disabled (AUTOENV_DISABLED)."
+    return
+  fi
+
+  local env_file="$PWD/$AUTOENV_FILE_ENTER"
+  _autoenv_debug "env_file: $env_file"
+
   # Handle leave event for previously sourced env files.
   if [[ $AUTOENV_HANDLE_LEAVE == 1 ]] && (( $#_autoenv_stack_entered )); then
     local prev_file prev_dir