Last active
March 14, 2018 09:53
-
-
Save jcaromiq/e5c0079c9fd15db5c8f02d015596fe54 to your computer and use it in GitHub Desktop.
Hook to execute file with name .env.sh if exists when change directory
This file contains 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
source_env() { | |
if [ ! -z "$1" ]; then | |
1=$(realpath $1) | |
if [[ "$1" != "/" ]]; then | |
source_env "$1/.." | |
env_file="$1/.env.sh" | |
if [[ -e $env_file ]]; then | |
source $env_file | |
fi | |
fi | |
fi | |
} | |
function chpwd() { | |
emulate -L zsh | |
source_env "." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment