For performance reasons, we prefer detecting Homebrew prefix internally
instead of the more idiomatic form `brew --prefix`.
We attempt looking up $HOMEBREW_PREFIX or $HOMEBREW_REPOSITORY first (in
case `brew shellenv` has been sourced-in earlier). Else, we look it up
by resolving absolute path of $HOMEBREW_REPOSITORY. $HOMEBREW_PREFIX is
same as $HOMEBREW_REPOSITORY except when Homebrew is installed in
'/usr/local' ($HOMEBREW_REPOSITORY == '/usr/local/Homebrew'). This is
usually the case for Intel Macs.
This should work for most standard (and officially documented) Homebrew
installations.
For implementation details in Homebrew,
see: 2a850e02d8/bin/brew (L62-L70)
Co-authored-by: mattmc3 <mattmc3@gmail.com>
Unset `curl_prefix` outside condition block so that it is always
cleared. Also, avoid `brew --prefix <foo>` since it is triggering ruby
in fallback flow when `<foo>` is not present.
Also, apply minor formatting tweaks.
Set `LS_COLORS` if not already available so that it is available as
standard style `list-colors`.
This needs to be explicitly set in completion module to ensure that the
variable is available even if 'utility' module is not loaded earlier.
As curl bundled with macOS does not include `_curl` definitions, one
way to make `_curl` available is to install curl from Homebrew.
However, since curl from Hombrew is _keg-only_, its function path needs
to be explicitly included.
`compinit -i` doesn't always change zcompdump, which means that the
`compinit -C` condition fails to run until the completions change.
When we `compinit -i`, we should touch the file too to solve this.
- Add missing documentation for options and environment variables
- Rearrange definition and documentation of 'Options', 'Variables'
and 'Aliases' in a consistent order
By keeping the variable `_etc_host_ignores` around, it can be resolved
lazily which is turn should allow selective ignores on a per invocation
basis.
Also, `'\#'` doesn't need to be added to `_etc_host_ignores` anymore.
It is enforced inline.
Entries from static '/etc/hosts' can now be ignored via 'zstyle' based
configuration. Both IP address and corresponding hostname will be ignored
during host completion. However, some of the entries ignored from '/etc/hosts'
still might appear during completion because of their presence in 'ssh'
configuration ('~/.ssh/config') or history ('~/.ssh/ssh_hosts',
'~/.ssh/known_hosts' etc.).
Usage of `(( ... ))` over `[[ ... ]]` is preferred for arithmetic expression
since the former is less error prone.
Also, unset local variable whenever possible.
The original idea was by @samjonester in #1210. This version aims to avoid
relying on the stat or date programs because they have different flags depending
on the OS and if it uses BSD or GNU coreutils.
7 is pretty arbitrarily chosen, but seems like a reasonable tradeoff, at
least the completion no longer shows symptoms of exponential
time-growth when trying to complete something completely wrong.
This fixes#946.