8000 GitHub - shoekstra/env-zsh: Automatically load environment variables from a .env file in the current working directory.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Automatically load environment variables from a .env file in the current working directory.

License

Notifications You must be signed in to change notification settings

shoekstra/env-zsh

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Env zsh plugin

This plugin automatically loads any environment variables in any file called .env when it exists in the current working directory. This plugin will load .env in two situations:

  • When the shell first starts (e.g. you open a new window or tab).
  • When you change the current working directory.

There's a caveat: because this plugin uses source, any changes you make will persist for as long as the shell is alive. For example, if two directories (e.g. two different software projects) rely on the same variable (e.g. PORT), you'll need to make sure that both .env files set that variable, or that neither do. Otherwise, you'll get unexpected behaviour. TL;DR: When in doubt, re-initialize all state in each .env file.

Installation

Assuming you have Oh-my-zsh installed, you should be able to install env like any other zsh plugin. (In particular, notice that the git clone line specifies a different target directory, env, than what would be the default, env-zsh.)

cd ~/.oh-my-zsh/plugins
git clone https://github.com/shoekstra/env-zsh.git env

Once the plugin is installed, you can enable it by editing your plugin list in ~.zshrc:

...
plugins=(... env)
...

Once you've saved ~/.zshrc, you'll need to reload it with source ~/.zshrc.

Usage

Create a .env file in your directory of choice and define environment variables in a KEY=VAL format, each on it's own line. The next time you change into that directory, or start a new shell in that directory, the .env contents will be exported as shell variables.

Thanks

Special thanks to John Hamelink, who created env-zsh, and Michael Schoonmaker, who created userenv-zsh, upon which this plugin is based.

About

Automatically load environment variables from a .env file in the current working directory.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%
0