Skip to content

Instantly share code, notes, and snippets.

@dryan
Last active December 16, 2015 05:29
Show Gist options
  • Select an option

  • Save dryan/5384505 to your computer and use it in GitHub Desktop.

Select an option

Save dryan/5384505 to your computer and use it in GitHub Desktop.
activate a virtualenv if present on cd. additionally, if a "set_env.sh" file is present with environment variables, load those in.
# add this to the end of your .bashrc, .zshrc or equivalent
function cd() {
builtin cd "$@"
if [ -f "bin/activate" ]
then
source "bin/activate"
elif [ -f "../bin/activate" ]
then
source "../bin/activate"
else
fi
if [ -f "set_env.sh" ]
then
source "set_env.sh"
fi
}
export ENVIRONMENT_VARIABLE_NAME = "value"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment