Commit graph

8 commits

Author SHA1 Message Date
Mislav Marohnić
901faec464 Only colorize warning messages if stderr is a tty
This is to avoid outputting ANSI escape codes to scripts and log files.
2015-10-23 12:26:11 -04:00
Mislav Marohnić
ed8619e0ab Detect if ~/.zshenv.local changes PATH and suggest .zshrc instead
Warn people who might have PATH and similar configuration in their
`~/.zshenv.local` that they should upgrade to `~/.zshrc.local` since
that's a much better phase for such configuration. This is for backwards
compatibility with people's personal configurations from pre-El Capitan
days.

The generic `.zshenv` file from zsh distribution[1] advises:

> .zshenv is sourced on ALL invocations of the shell, unless the -f
> option is set. It should NOT normally contain commands to set the
> command search path, or other common environment variables unless you
> really know what you're doing. E.g. running `PATH=/custom/path gdb program`
> sources this file (when gdb runs the program via $SHELL), so you want
> to be sure not to override a custom environment in such cases. Note
> also that .zshenv should not contain commands that produce output or
> assume the shell is attached to a tty.

[1]: http://sourceforge.net/p/zsh/code/ci/master/tree/StartupFiles/zshenv
2015-10-23 12:26:10 -04:00
Mislav Marohnić
febd718efe Move EDITOR and PATH tweaks from .zshenv to .zshrc
Making tweaks such as setting EDITOR or changing PATH only makes sense
for interactive shells, e.g. those that open in your Terminal window or
when you log in to a server. Non-interactive shells (such as those
started by running `zsh myscript.zsh` or any executable with `zsh`
shebang) should instead inherit those values from the environment.

Furthermore, changing PATH in `~/.zshenv` is not advised since stock
OS X `/etc/zprofile` will reoder PATH by means of `path_helper`, so it's
better to make any additional PATH manipulation in `~/.zprofile` or
`~/.zshrc`.
2015-10-23 12:24:51 -04:00
Valentino
9aa2cd5026 Use command -v instead of which in conditionals
Reason: https://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script/677212#677212
2015-10-16 09:03:28 -04:00
Greg Lazarev
fe180f78d5 Fix typo in zshenv path 2014-11-14 13:08:16 -08:00
Daniel Nolan
be8e18a880 Revert adding /usr/local/bin to path in zshenv
* Adding /usr/local/bin to path in `~/.zshenv` causes it to be in my path twice one right after the other. /usr/local/bin is already added to the path in the correct order on OSX Yosemite by the /etc/paths file. 

* Remove /usr/local/bin from path export in zshenv
2014-11-14 11:16:46 -08:00
Derek Prior
de8543e54f
Add /usr/local/sbin to PATH
Some homebrew formulae, (e.g. [RabbitMQ][1]) link binaries here.

[1]: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/rabbitmq.rb
2014-10-28 22:25:22 -04:00
Robert Speicher
6a1bd18a1f Add zshenv file
From the [Zsh manual](http://zsh.sourceforge.net/Intro/intro_3.html):

> '.zshenv' is sourced on all invocations of the shell, unless the -f option is
> set. It should contain commands to set the command search path, plus other
> important environment variables. `.zshenv' should not contain commands that
> produce output or assume the shell is attached to a tty.

Why is this important? [Alfred](http://www.alfredapp.com/) workflows run in
non-interactive shells. When the `$PATH` is set, or `rbenv` is initialized, in
`zshrc` instead of `zshenv`, those workflows will not use the correct Ruby
version and might not have access to certain bin files, such as those from
`$HOME/.bin/` or Homebrew.
2014-09-12 11:45:03 -07:00