Created
February 11, 2020 10:43
-
-
Save 11philip22/90f48c6e37f817165fe1fdbc9a5d708e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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