How to automatically set environment variables per folder (directory) on bash shell on macOS High Sierra

I have a little CLI toy project that uses the file system for storage (YAML files) and defaults to a dot folder under the home folder (~), this default can be overridden by an environment variable that sets the path. To ease manual testing, I wanted to automatically set up an environment variable wheneve I cd’ed into the project folder, also as bonus I wanted this variable to be removed from the environment whenever I cd’ed  out. Googling a bit,

Site Footer