Makes fzf availalbe in other shells.
This commit is contained in:
78
.rc.d/fzf.sh
78
.rc.d/fzf.sh
@@ -1,16 +1,64 @@
|
||||
# To set up shell integration, add this to your shell configuration file:
|
||||
# # bash
|
||||
# eval "$(fzf --bash)"
|
||||
|
||||
# # zsh
|
||||
# source <(fzf --zsh)
|
||||
|
||||
# # fish
|
||||
# fzf --fish | source
|
||||
|
||||
# To use fzf in Vim, add the following line to your .vimrc:
|
||||
# set rtp+=/opt/homebrew/opt/fzf
|
||||
|
||||
if [ -x "$(which fzf)" ]; then
|
||||
source <(fzf --zsh)
|
||||
# Setup fzf shell integration (bash, zsh, and fallback paths)
|
||||
_setup_fzf() {
|
||||
# Ensure fzf binary is accessible if installed in common locations
|
||||
if ! command -v fzf >/dev/null 2>&1; then
|
||||
for _fzf_bin_dir in \
|
||||
"/opt/homebrew/bin" \
|
||||
"/usr/local/bin" \
|
||||
"$HOME/.fzf/bin" \
|
||||
"$HOME/.local/bin"
|
||||
do
|
||||
if [ -x "$_fzf_bin_dir/fzf" ]; then
|
||||
case ":$PATH:" in
|
||||
*":$_fzf_bin_dir:"*) ;;
|
||||
*) PATH="$_fzf_bin_dir:$PATH"; export PATH ;;
|
||||
esac
|
||||
break
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user