zsh/fzf.zsh

36 lines
1 KiB
Bash
Raw Normal View History

#! /bin/zsh
2023-10-05 10:14:04 +02:00
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
#
# SPDX-License-Identifier: GPL-3.0-or-later
# shellcheck shell=bash
2023-10-05 10:14:04 +02:00
# shellcheck disable=1091
2023-07-10 12:31:40 +02:00
export FZF_COMPLETION_OPTS='--border --info=inline'
2023-07-12 08:37:25 +02:00
if [ -n "$TERMUX_VERSION" ] && [ -d "$PREFIX" ];
then
2023-10-05 10:14:04 +02:00
source "$PREFIX/share/fzf/completion.zsh"
source "$PREFIX/share/fzf/key-bindings.zsh"
2023-07-12 08:37:25 +02:00
else
2023-10-05 10:14:04 +02:00
source /usr/share/doc/fzf/examples/completion.zsh
source /usr/share/doc/fzf/examples/key-bindings.zsh
2023-07-12 08:37:25 +02:00
fi
2023-07-10 12:31:40 +02:00
# (EXPERIMENTAL) Advanced customization of fzf options via _fzf_comprun function
# - The first argument to the function is the name of the command.
# - You should make sure to pass the rest of the arguments to fzf.
_fzf_comprun() {
2023-10-05 10:14:04 +02:00
local command=$1
shift
2023-07-10 12:31:40 +02:00
2023-10-05 10:14:04 +02:00
case "$command" in
vim|nvim|nano) fzf "$@" --preview 'batcat --color=always {}' ;;
cd) fzf "$@" --preview 'tree -C {} | head -200' ;;
export|unset) fzf "$@" --preview "eval 'echo \$'{}" ;;
ssh) fzf "$@" --preview 'dig {}' ;;
*) fzf "$@" ;;
esac
2023-07-10 12:31:40 +02:00
}