This repository has been archived on 2024-04-30. You can view files and clone it, but cannot push or open issues or pull requests.
setup/roles/bash/files/fzf.bash

36 lines
1.2 KiB
Bash
Raw Normal View History

2023-02-26 00:17:16 +00:00
export FZF_DEFAULT_COMMAND=fdfind
2023-01-15 14:00:38 +00:00
# Options to fzf command
export FZF_COMPLETION_OPTS='--border --info=inline'
# Use fd (https://github.com/sharkdp/fd) instead of the default find
# command for listing path candidates.
# - The first argument to the function ($1) is the base path to start traversal
# - See the source code (completion.{bash,zsh}) for the details.
_fzf_compgen_path() {
2023-02-13 23:13:10 +00:00
fdfind --type file --hidden --follow --exclude ".git" . "$1"
2023-01-15 14:00:38 +00:00
}
# Use fd to generate the list for directory completion
_fzf_compgen_dir() {
fdfind --type d --hidden --follow --exclude ".git" . "$1"
}
# 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() {
local command=$1
shift
case "$command" in
cd) fzf --preview 'tree -C {} | head -200' "$@" ;;
export|unset) fzf --preview "eval 'echo \$'{}" "$@" ;;
ssh) fzf --preview 'dig {}' "$@" ;;
*) fzf --preview 'batcat -n --color=always {}' "$@" ;;
esac
}
2023-02-26 00:17:16 +00:00
source /usr/share/doc/fzf/examples/completion.bash
2023-02-13 23:13:10 +00:00
source /usr/share/doc/fzf/examples/key-bindings.bash