refactor(fzf): adopt code style and simplify function naming (#10514)

This commit is contained in:
Logan Linn 2021-12-17 04:18:28 -08:00 committed by GitHub
parent 41c15a2159
commit 010c36d4ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 137 additions and 137 deletions

View File

@ -1,4 +1,4 @@
function setup_using_base_dir() {
function fzf_setup_using_base_dir() {
local fzf_base fzf_shell fzfdirs dir
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
@ -58,7 +58,7 @@ function setup_using_base_dir() {
}
function setup_using_debian_package() {
function fzf_setup_using_debian() {
if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then
# Either not a debian based distro, or no fzf installed
return 1
@ -96,7 +96,7 @@ function setup_using_debian_package() {
return 0
}
function setup_using_opensuse_package() {
function fzf_setup_using_opensuse() {
# OpenSUSE installs fzf in /usr/bin/fzf
# If the command is not found, the package isn't installed
(( $+commands[fzf] )) || return 1
@ -125,7 +125,7 @@ function setup_using_opensuse_package() {
return 0
}
function setup_using_openbsd_package() {
function fzf_setup_using_openbsd() {
# openBSD installs fzf in /usr/local/bin/fzf
if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then
return 1
@ -149,21 +149,21 @@ function setup_using_openbsd_package() {
return 0
}
function indicate_error() {
cat >&2 <<EOF
# Indicate to user that fzf installation not found if nothing worked
function fzf_setup_error() {
cat >&2 <<'EOF'
[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc
Please add `export FZF_BASE=/path/to/fzf/install/dir` to your .zshrc
EOF
}
# Indicate to user that fzf installation not found if nothing worked
setup_using_openbsd_package \
|| setup_using_debian_package \
|| setup_using_opensuse_package \
|| setup_using_base_dir \
|| indicate_error
fzf_setup_using_openbsd \
|| fzf_setup_using_debian \
|| fzf_setup_using_opensuse \
|| fzf_setup_using_base_dir \
|| fzf_setup_error
unset -f setup_using_opensuse_package setup_using_debian_package setup_using_base_dir indicate_error
unset -f -m 'fzf_setup_*'
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
if (( $+commands[rg] )); then