Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Oh My Zsh
Commits
b90f76c1
Commit
b90f76c1
authored
Jul 15, 2019
by
Ilya Gorski
Browse files
fzf: Adding support for debian packages
parent
17f4cfca
Changes
1
Show whitespace changes
Inline
Side-by-side
plugins/fzf/fzf.plugin.zsh
View file @
b90f76c1
test
-d
"
${
FZF_BASE
}
"
&&
fzf_base
=
"
${
FZF_BASE
}
"
function
setup_using_base_dir
()
{
# Declare all variables local not no mess with outside env in any way
local
fzf_base
local
fzf_shell
local
fzfdirs
local dir
if
[[
-z
"
${
fzf_base
}
"
]]
;
then
test
-d
"
${
FZF_BASE
}
"
&&
fzf_base
=
"
${
FZF_BASE
}
"
if
[[
-z
"
${
fzf_base
}
"
]]
;
then
fzfdirs
=(
fzfdirs
=(
"
${
HOME
}
/.fzf"
"
${
HOME
}
/.fzf"
"/usr/local/opt/fzf"
"/usr/local/opt/fzf"
...
@@ -20,10 +27,9 @@ if [[ -z "${fzf_base}" ]]; then
...
@@ -20,10 +27,9 @@ if [[ -z "${fzf_base}" ]]; then
fi
fi
fi
fi
fi
fi
fi
fi
if
[[
-n
"
${
fzf_base
}
"
]]
;
then
if
[[
-d
"
${
fzf_base
}
"
]]
;
then
# Fix fzf shell directory for Archlinux package
# Fix fzf shell directory for Archlinux package
if
[[
!
-d
"
${
fzf_base
}
/shell"
]]
&&
[[
-f
/etc/arch-release
]]
;
then
if
[[
!
-d
"
${
fzf_base
}
/shell"
]]
&&
[[
-f
/etc/arch-release
]]
;
then
fzf_shell
=
"
${
fzf_base
}
"
fzf_shell
=
"
${
fzf_base
}
"
...
@@ -31,27 +37,57 @@ if [[ -n "${fzf_base}" ]]; then
...
@@ -31,27 +37,57 @@ if [[ -n "${fzf_base}" ]]; then
fzf_shell
=
"
${
fzf_base
}
/shell"
fzf_shell
=
"
${
fzf_base
}
/shell"
fi
fi
# Setup fzf
# Setup fzf binary path
# ---------
if
!
((
${
+commands[fzf]
}
))
&&
[[
!
"
$PATH
"
==
*
$fzf_base
/bin
*
]]
;
then
if
!
((
${
+commands[fzf]
}
))
&&
[[
!
"
$PATH
"
==
*
$fzf_base
/bin
*
]]
;
then
export
PATH
=
"
$PATH
:
$fzf_base
/bin"
export
PATH
=
"
$PATH
:
$fzf_base
/bin"
fi
fi
# Auto-completion
# Auto-completion
# ---------------
if
[[
!
"
$DISABLE_FZF_AUTO_COMPLETION
"
==
"true"
]]
;
then
if
[[
!
"
$DISABLE_FZF_AUTO_COMPLETION
"
==
"true"
]]
;
then
[[
$-
==
*
i
*
]]
&&
source
"
${
fzf_shell
}
/completion.zsh"
2> /dev/null
[[
$-
==
*
i
*
]]
&&
source
"
${
fzf_shell
}
/completion.zsh"
2> /dev/null
fi
fi
# Key bindings
# Key bindings
# ------------
if
[[
!
"
$DISABLE_FZF_KEY_BINDINGS
"
==
"true"
]]
;
then
if
[[
!
"
$DISABLE_FZF_KEY_BINDINGS
"
==
"true"
]]
;
then
source
"
${
fzf_shell
}
/key-bindings.zsh"
source
"
${
fzf_shell
}
/key-bindings.zsh"
fi
fi
else
return
1
fi
}
function
setup_using_debian_package
()
{
dpkg
-s
fzf &> /dev/null
if
((
$?
))
;
then
# Either not a debian based distro, or no fzf installed. In any case skip ahead
return
1
fi
# NOTE: There is no need to configure PATH for debian package, all binaries
# are installed to /usr/bin by default
local
completions
=
"/usr/share/zsh/vendor-completions/_fzf"
local
key_bindings
=
"/usr/share/doc/fzf/examples/key-bindings.zsh"
# Auto-completion
if
[[
$-
==
*
i
*
]]
&&
[[
!
"
$DISABLE_FZF_AUTO_COMPLETION
"
==
"true"
]]
;
then
source
$completions
2> /dev/null
fi
# Key bindings
if
[[
!
"
$DISABLE_FZF_KEY_BINDINGS
"
==
"true"
]]
;
then
source
$key_bindings
fi
return
0
}
else
function
indicate_error
()
{
print
"[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
\n
"
\
print
"[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
\n
"
\
"Please add
\`
export FZF_BASE=/path/to/fzf/install/dir
\`
to your .zshrc"
>
&2
"Please add
\`
export FZF_BASE=/path/to/fzf/install/dir
\`
to your .zshrc"
>
&2
fi
}
unset
fzf_base fzf_shell
dir
fzfdirs
# Check for debian package first, because it easy to short cut
# Indicate to user that fzf installation not found if nothing worked
setup_using_debian_package
||
setup_using_base_dir
||
indicate_error
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment