52a46ec362389429049cc36b0806627db02f099e

Author
Sean Flanigan <sean@flanigan.org>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

feat(fzf): support fzf in Cygwin (#9463)

Closes #9463

Diff

 1diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh
 2index 50712cbee6c4fb8b9ca1ad91b5f24cf1cf710171..1026059588f09d6ba5c891011684928b9116a288 100644
 3--- a/plugins/fzf/fzf.plugin.zsh
 4+++ b/plugins/fzf/fzf.plugin.zsh
 5@@ -149,6 +149,30 @@ function fzf_setup_using_openbsd() {
 6   return 0
 7 }
 8 
 9+function fzf_setup_using_cygwin() {
10+  # Cygwin installs fzf in /usr/local/bin/fzf
11+  if [[ "$OSTYPE" != cygwin* ]] || (( ! $+commands[fzf] )); then
12+    return 1
13+  fi
14+
15+  # The fzf-zsh-completion package installs the auto-completion in
16+  local completions="/etc/profile.d/fzf-completion.zsh"
17+  # The fzf-zsh package installs the key-bindings file in
18+  local key_bindings="/etc/profile.d/fzf.zsh"
19+
20+  # Auto-completion
21+  if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
22+    source "$completions" 2>/dev/null
23+  fi
24+
25+  # Key bindings
26+  if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
27+    source "$key_bindings" 2>/dev/null
28+  fi
29+
30+  return 0
31+}
32+
33 # Indicate to user that fzf installation not found if nothing worked
34 function fzf_setup_error() {
35   cat >&2 <<'EOF'
36@@ -160,6 +184,7 @@ EOF
37 fzf_setup_using_openbsd \
38   || fzf_setup_using_debian \
39   || fzf_setup_using_opensuse \
40+  || fzf_setup_using_cygwin \
41   || fzf_setup_using_base_dir \
42   || fzf_setup_error
43