diff options
author | neodarz <neodarz@neodarz.net> | 2017-05-04 03:27:33 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2017-05-04 03:27:33 +0200 |
commit | 785bde84dd4888817bb9825ba5ab388ec2b7c4b7 (patch) | |
tree | eb572026c9c953dbd67e3acc2104db11117b4e5f /source/blog/2015-12-26-autoenv-with-auto-cleanup.md | |
parent | 15c05dbb86fe3d98ec6e6ebe7743fd85b860dcc6 (diff) | |
download | my_new_personal_website-785bde84dd4888817bb9825ba5ab388ec2b7c4b7.tar.xz my_new_personal_website-785bde84dd4888817bb9825ba5ab388ec2b7c4b7.zip |
Update to date
Diffstat (limited to '')
-rw-r--r-- | source/blog/2015-12-26-autoenv-with-auto-cleanup.md | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/source/blog/2015-12-26-autoenv-with-auto-cleanup.md b/source/blog/2015-12-26-autoenv-with-auto-cleanup.md deleted file mode 100644 index dd973a40..00000000 --- a/source/blog/2015-12-26-autoenv-with-auto-cleanup.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: "autoenv with auto cleanup" -date: 2015-12-26T00:15:48-08:00 -date_display: December 26, 2015 ---- - -I heard about [kennethreitz/autoenv](https://github.com/kennethreitz/autoenv) a long time ago. The idea of autoloading project-specific environment modifications is nice, but no auto cleanup after leaving a project was a showstopper for me. - -Today, I took matters into my own hands and wrote a fresh Zsh implementation[^re] with auto cleanup support. Check it out: <https://github.com/zmwangx/prezto/tree/master/modules/autoenv>. - -[^re]: This is not a re-implementation in the common sense. My little Zsh module is inspired by kennethreitz/autoenv and reminiscent of that older project, but I took nothing from there (in fact I didn't even read their source code). I also don't claim to support their entire feature set. For instance, kennethreitz/autoenv claims to be Foreman compatible, which includes turning on `ALL_EXPORT`. However, I don't think `ALL_EXPORT` by default is a good idea, so with my `autoenv`, if you want `ALL_EXPORT` you have to set it explicitly. - -As a quick promotion, let me show you two common examples. - -First, inserting some local bin directory into the search path. This is easily done by a one-line `.env`, say, - -```zsh -autoenv-insert-paths bin libexec -``` - -This way `$PWD/bin` and `$PWD/libexec` are inserted to the beginning of the search path, which will persist until you leave the directory tree. That is to say, the inserted paths will still be available when you descend into subdirectories (and more specific `.env`'s can even be stacked as you descend), but they will be purged as soon as you leave the tree. Clever, isn't it? - -Secondly, exporting project-specific environment variables. The `.env` would look like - -```zsh -export HOMEBREW_DEVELOPER=not-for-the-faint-hearted - -autoenv-purge () unset HOMEBREW_DEVELOPER -``` - -where the body of `autoenv-purge` will be executed when you leave the directory tree. No more junk floating around. - -Again, for more info, including detailed usage and customization instructions, please visit [`modules/autoenv`](https://github.com/zmwangx/prezto/tree/master/modules/autoenv) in zmwangx/prezto. |