Skip to content

Commit 0024a87

Browse files
authored
Merge pull request #124 from unixorn/fix-brew-issue
Check if `fzf` was installed by `brew`
2 parents 68419c3 + c7a3ff1 commit 0024a87

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

fzf-settings.zsh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,32 @@ if [[ ! "$PATH" == *${FZF_PATH}/bin* ]]; then
44
export PATH="$PATH:${FZF_PATH}/bin"
55
fi
66

7+
function _fzf_has() {
8+
which "$@" > /dev/null 2>&1
9+
}
10+
11+
if _fzf_has brew; then
12+
# If fzf was installed via brew, use the brew paths
13+
if [[ -x "$(brew --prefix)/bin/fzf" ]]; then
14+
if [[ -f "$(brew --prefix fzf)/shell/completion.zsh" ]]; then
15+
source "$(brew --prefix fzf)/shell/completion.zsh" 2> /dev/null
16+
fi
17+
if [[ -f "$(brew --prefix fzf)/shell/key-bindings.zsh" ]]; then
18+
source "$(brew --prefix fzf)/shell/key-bindings.zsh"
19+
fi
20+
fi
21+
fi
22+
723
# Auto-completion
824
# ---------------
9-
[[ $- == *i* ]] && source "${FZF_PATH}/shell/completion.zsh" 2> /dev/null
25+
if [[ -f "${FZF_PATH}/shell/completion.zsh" ]]; then
26+
[[ $- == *i* ]] && source "${FZF_PATH}/shell/completion.zsh" 2> /dev/null
27+
fi
1028

1129
# Key bindings
1230
# ------------
13-
source "${FZF_PATH}/shell/key-bindings.zsh"
31+
if [[ -f "${FZF_PATH}/shell/key-bindings.zsh" ]]; then
32+
source "${FZF_PATH}/shell/key-bindings.zsh"
33+
fi
34+
35+
unset -f _fzf_has

0 commit comments

Comments
 (0)