Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This little shell function allows to set environment variables when you cd into that directory.
# Note: this is just a fragment that you should put in your ~/.bash_profile
# Tested on Mac only!
#
# If you want a more sophisticated and feature rich solution here are some pointers:
# - https://github.com/cxreg/smartcd
# - http://swapoff.org/ondir.html
function cd_ {
if [ -e .env_off ] ; then
. .env_off
fi
builtin cd "$*"
if [ -e .env ] ; then
. .env
fi
}
alias cd=cd_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.