Makes fzf availalbe in other shells.

This commit is contained in:
2026-09-07 17:48:28 -07:00
parent 97dbb80e2c
commit 1544056ab9

View File

@@ -1,16 +1,64 @@
# To set up shell integration, add this to your shell configuration file: # Setup fzf shell integration (bash, zsh, and fallback paths)
# # bash _setup_fzf() {
# eval "$(fzf --bash)" # Ensure fzf binary is accessible if installed in common locations
if ! command -v fzf >/dev/null 2>&1; then
# # zsh for _fzf_bin_dir in \
# source <(fzf --zsh) "/opt/homebrew/bin" \
"/usr/local/bin" \
# # fish "$HOME/.fzf/bin" \
# fzf --fish | source "$HOME/.local/bin"
do
# To use fzf in Vim, add the following line to your .vimrc: if [ -x "$_fzf_bin_dir/fzf" ]; then
# set rtp+=/opt/homebrew/opt/fzf case ":$PATH:" in
*":$_fzf_bin_dir:"*) ;;
if [ -x "$(which fzf)" ]; then *) PATH="$_fzf_bin_dir:$PATH"; export PATH ;;
source <(fzf --zsh) esac
break
fi fi
done
fi
command -v fzf >/dev/null 2>&1 || return 0
if [ -n "$BASH_VERSION" ]; then
if fzf --bash >/dev/null 2>&1; then
eval "$(fzf --bash)"
else
# Fallback for older fzf versions
for _dir in \
"/opt/homebrew/opt/fzf/shell" \
"/usr/local/opt/fzf/shell" \
"$HOME/.fzf/shell" \
"/usr/share/doc/fzf/examples" \
"/usr/share/fzf"
do
if [ -d "$_dir" ]; then
[ -r "$_dir/completion.bash" ] && \. "$_dir/completion.bash"
[ -r "$_dir/key-bindings.bash" ] && \. "$_dir/key-bindings.bash"
break
fi
done
fi
elif [ -n "$ZSH_VERSION" ]; then
if fzf --zsh >/dev/null 2>&1; then
eval "$(fzf --zsh)"
else
# Fallback for older fzf versions
for _dir in \
"/opt/homebrew/opt/fzf/shell" \
"/usr/local/opt/fzf/shell" \
"$HOME/.fzf/shell" \
"/usr/share/doc/fzf/examples" \
"/usr/share/fzf"
do
if [ -d "$_dir" ]; then
[ -r "$_dir/completion.zsh" ] && \. "$_dir/completion.zsh"
[ -r "$_dir/key-bindings.zsh" ] && \. "$_dir/key-bindings.zsh"
break
fi
done
fi
fi
}
_setup_fzf
unset -f _setup_fzf