[zsh] Implement a homebrew-prefix function and use it when setting up fpath
# Conflicts: # zshrc
This commit is contained in:
parent
a2bf66480c
commit
ddf3de5a80
3 changed files with 23 additions and 3 deletions
19
zsh/func/homebrew-prefix
Normal file
19
zsh/func/homebrew-prefix
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
autoload binary_exists
|
||||||
|
|
||||||
|
function homebrew-prefix
|
||||||
|
{
|
||||||
|
if [[ -e "$SYSTEM_PARAMETERS_FILE" ]] && binary_exists jq; then
|
||||||
|
jq .parameters.homebrew_prefix.value "$SYSTEM_PARAMETERS_FILE"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! binary_exists brew; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
brew --prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
homebrew-prefix "$@"
|
|
@ -1,11 +1,12 @@
|
||||||
# Eryn Wells <eryn@erynwells.me>
|
# Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
autoload -Uz binary_exists
|
autoload binary_exists
|
||||||
|
autoload homebrew-prefix
|
||||||
|
|
||||||
function init_rc_fpath_darwin
|
function init_rc_fpath_darwin
|
||||||
{
|
{
|
||||||
if binary_exists brew; then
|
if binary_exists brew; then
|
||||||
local brew_fpath="$(brew --prefix)/share/zsh/site-functions"
|
local brew_fpath="$(homebrew-prefix)/share/zsh/site-functions"
|
||||||
if [[ -d "$brew_fpath" ]]; then
|
if [[ -d "$brew_fpath" ]]; then
|
||||||
fpath+=($brew_fpath)
|
fpath+=($brew_fpath)
|
||||||
fi
|
fi
|
||||||
|
|
2
zshrc
2
zshrc
|
@ -21,4 +21,4 @@ autoload -Uz nethack
|
||||||
autoload -Uz pw
|
autoload -Uz pw
|
||||||
autoload -Uz up
|
autoload -Uz up
|
||||||
autoload -Uz vi
|
autoload -Uz vi
|
||||||
autoload -Uz open-xcode
|
autoload -Uz homebrew-prefix
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue