sorin-ionescu/prezto — pull request #500 by nyobe (2013-11-22 21:51:30+00:00)
Title: Don't override customized environments in subshells

Prezto unconditionally sets up the $PATH in zshenv, which is sourced for every shell invocation. As a result, subshells will not correctly inherit changes to the path, which is desirable for doing things like temporarily overriding commands (eg, in a [virtualenv](https://github.com/berdario/invewrapper/)). This patch makes sure that the path is only set for top-level shells- either login shells, or interactive shells with shell-level 1.

It was inspired by this [this message](http://www.zsh.org/mla/users/2003/msg00600.html) from the zsh-users-help mailing list archive:
```
# Some people insist on setting their PATH (in zshenv) to affect things like ssh.
# Those that do should probably use $SHLVL to ensure that this only happens
# the first time the shell is started (to avoid overriding a customized
# environment). Also, the various profile/rc/login files all get sourced
# *after* this file, so they will override this value. One solution is to
# put your path-setting code into a file named .zpath, and source it from
# both here (if we're not a login shell) and from the .zprofile file (which
# is only sourced if we are a login shell).
```