4dce175e0e4a678b7f93be80c64247c8f5fbab3e

Author
Suchandra Thapa <suchandra+github@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(fzf): support `fzf` installed with MacPorts (#10794)

Diff

 1diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh
 2index b86af0d2d1fec588274972c9cd79020047af28b1..a946cf7625c5f3a3113e07d42957630ba76b0c9c 100644
 3--- a/plugins/fzf/fzf.plugin.zsh
 4+++ b/plugins/fzf/fzf.plugin.zsh
 5@@ -173,6 +173,32 @@ function fzf_setup_using_cygwin() {
 6   return 0
 7 }
 8 
 9+function fzf_setup_using_macports() {
10+  # If the command is not found, the package isn't installed
11+  (( $+commands[fzf] )) || return 1
12+
13+  # The fzf-zsh-completion package installs the auto-completion in
14+  local completions="/opt/local/share/zsh/site-functions/fzf"
15+  # The fzf-zsh-completion package installs the key-bindings file in
16+  local key_bindings="/opt/local/share/fzf/shell/key-bindings.zsh"
17+
18+  if [[ ! -f "$completions" || ! -f "$key_bindings" ]]; then
19+    return 1
20+  fi
21+
22+  # Auto-completion
23+  if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
24+    source "$completions" 2>/dev/null
25+  fi
26+
27+  # Key bindings
28+  if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
29+    source "$key_bindings" 2>/dev/null
30+  fi
31+
32+  return 0
33+}
34+
35 # Indicate to user that fzf installation not found if nothing worked
36 function fzf_setup_error() {
37   cat >&2 <<'EOF'
38@@ -185,6 +211,7 @@ fzf_setup_using_openbsd \
39   || fzf_setup_using_debian \
40   || fzf_setup_using_opensuse \
41   || fzf_setup_using_cygwin \
42+  || fzf_setup_using_macports \
43   || fzf_setup_using_base_dir \
44   || fzf_setup_error
45