Skip to content

Instantly share code, notes, and snippets.

@11philip22
Created February 11, 2020 10:43
Show Gist options
  • Save 11philip22/90f48c6e37f817165fe1fdbc9a5d708e to your computer and use it in GitHub Desktop.
Save 11philip22/90f48c6e37f817165fe1fdbc9a5d708e to your computer and use it in GitHub Desktop.
function read_env() {
if builtin cd "$@"; then
local env="$PWD/.zenv"
if [ -f "$env" ]; then
if [ -z "$CURRENT_ENV" ]; then
builtin source "$env"
export CURRENT_ENV="$env"
elif [ ! "$CURRENT_ENV" = "$env" ]; then
if [ "$(type -t deactivate)" = "function" ]; then
deactivate
fi
builtin source "$env"
export CURRENT_ENV="$env"
fi
fi
fi
}
alias cd='read_env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment