I use oh-my-zsh for all of my console goodness. Depending on what I'm working on, there are certain environment variables that I'm often overwriting either manually or through scripts to make my work easier for the next hour. For example: setting default ssh identify files, changing the AWS_PROFILE env variable, clearing or resetting other custom environment variables.

I'd like to be able to switch to a different "environment" within a shell session based on some context, similar to how tools like RubyEnv and PyEnv work. Is there an easier way to do this in ZSH, either through a plugin or feature?

  • There is zsh-autoenv, which uses .autoenv.zsh and .autoenv_leave.zsh to handle enabling and disabling of different environment settings. Jul 10 '17 at 11:59

This comment mentions zsh-autoenv, but it does not appear to be maintained anymore.

I would recommend using direnv instead. It comes with Zsh support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.