Until recently, the default file name used by this plugin was
.env, but now it is.in. This is done in order not to conflict with.envfiles from numerous projects.
This plugin adds support for enter and leave events. By default .in files are used when entering a directory, and .out files when leaving a directory. And you can set variable CLICOLOR=1 for enabling colored output.
The environment variables $AUTOENV_IN_FILE & $AUTOENV_OUT_FILE can be used
to override the default values for the file names of .in & .out respectively.
- If you are in the directory
/home/user/dir1and executecd /var/www/myprojectthis plugin will source the following files if they exist
/home/user/dir1/.out
/home/user/.out
/home/.out
/var/.in
/var/www/.in
/var/www/myproject/.in
- If you are in the directory
/and executecd /home/user/dir1this plugin will source the following files if they exist
/home/.in
/home/user/.in
/home/user/dir1/.in
- If you are in the directory
/home/user/dir1and executecd /this plugin will source the following files if they exist
/home/user/dir1/.out
/home/user/.out
/home/.out
An envfile is sourced in the directory you moved to, not in its own. To reach files next to it use $(dirname $0); the directory it belongs to is also passed as the first argument to both .in and .out scripts. Don't use pwd or $PWD for this.
Earlier versions changed into the envfile's directory before sourcing it, so
$PWDhappened to point there. Doing that disturbed the directory stack,$OLDPWDandcd -, and it no longer happens. An envfile that used relative paths needs$(dirname $0)/in front of them.
nvm use node
OLDPATH=$PATH
export PATH="$(dirname $0)/node_modules/.bin":$PATHnvm use system
export PATH=$OLDPATHsource $(dirname $0)/.env*This plugin depends on zsh-colors.
If you don't use zpm, install it manually and activate it before this plugin. If you use zpm you don’t need to do anything
Using zpm
Add zpm load zpm-zsh/autoenv into .zshrc
Using oh-my-zsh
Execute git clone https://github.com/zpm-zsh/autoenv ~/.oh-my-zsh/custom/plugins/autoenv. Add autoenv into plugins array in .zshrc
Using Fig
Fig adds apps, shortcuts, and autocomplete to your existing terminal.
Install autoenv in just one click.
Using antigen
Add antigen bundle zpm-zsh/autoenv into .zshrc
Using zgen
Add zgen load zpm-zsh/autoenv into .zshrc
zsh test/run-tests.zsh # everything
zsh test/run-tests.zsh symlink # only scenarios matching a nameSourcing an envfile requires cd-ing into its directory, and a cd changes
four separate things: $PWD, the $OLDPWD parameter, zsh's internal
previous-directory record used by cd -, and the directory stack. The tests
run a navigation scenario twice -- once with the plugin loaded and once
without -- and require the resulting directory state to be identical, so the
plugin cannot leave any of them behind. Each scenario also asserts exactly
which envfiles ran, otherwise a plugin that did nothing at all would pass.
The remaining suites cover re-entry (an envfile that runs its own cd),
authorization (which envfiles are allowed to run at all), and loading (the
plugin's own entry point, which the other suites bypass).
To check the suite against a different checkout:
AUTOENV_TEST_PLUGIN=/path/to/autoenv zsh test/run-tests.zsh