Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/liliabat/public_html/com.usedtocode.i/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340
September 2018 – I used to code

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