Skip to content

Instantly share code, notes, and snippets.

@alexkiro
Created March 30, 2020 06:15
Show Gist options
  • Save alexkiro/ccf4b5283fb0147d5511f0626ba2ba94 to your computer and use it in GitHub Desktop.
Save alexkiro/ccf4b5283fb0147d5511f0626ba2ba94 to your computer and use it in GitHub Desktop.
Activate current env on cd
export ENV_PATHS=.venv/bin/activate:venv/bin/activate:env/bin/activate:../.venv/bin/activate:../venv/bin/activate:./bin/activate:.envrc
activate() {
for pos_file in $(echo $ENV_PATHS | tr ":" "\n")
do
if [ -f "$pos_file" ]
then
source "$pos_file"
fi
done
}
cd() {
builtin cd "$@" || return 1
activate
}
activate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment