Skip to content

Commit feb9198

Browse files
committed
feat: improve fzf config
1 parent 67d5d7f commit feb9198

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

Brewfile

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ brew 'tldr'
3030
brew 'bind' # used to have dig as binary
3131
brew 'nmap'
3232
brew 'fzf'
33+
brew 'fd'
3334
brew 'bat'
3435
brew 'fx'
3536
brew 'eza'

shell/.exports

+54-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,62 @@ export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=5'
3030
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
3131

3232
# FZF
33-
export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort' --layout=reverse --info=inline --preview 'cat {}' --border --margin=1 --padding=1"
33+
3434
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
3535

36+
# --- setup fzf theme ---
37+
fg="#CBE0F0"
38+
bg="#011628"
39+
bg_highlight="#143652"
40+
purple="#B388FF"
41+
blue="#06BCE4"
42+
cyan="#2CF9ED"
43+
44+
export FZF_DEFAULT_OPTS="--color=fg:${fg},bg:${bg},hl:${purple},fg+:${fg},bg+:${bg_highlight},hl+:${purple},info:${blue},prompt:${cyan},pointer:${cyan},marker:${cyan},spinner:${cyan},header:${cyan}"
45+
46+
export FZF_DEFAULT_OPTS="--info=inline
47+
--layout=reverse
48+
--bind='ctrl-o:execute(code {})+abort'
49+
--color=fg:${fg},bg:${bg},hl:${purple},fg+:${fg},bg+:${bg_highlight},hl+:${purple},info:${blue},prompt:${cyan},pointer:${cyan},marker:${cyan},spinner:${cyan},header:${cyan}"
50+
51+
export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git"
52+
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
53+
export FZF_ALT_C_COMMAND="fd --type=d --hidden --strip-cwd-prefix --exclude .git"
54+
55+
# Use fd (https://github.com/sharkdp/fd) for listing path candidates.
56+
# - The first argument to the function ($1) is the base path to start traversal
57+
# - See the source code (completion.{bash,zsh}) for the details.
58+
_fzf_compgen_path() {
59+
fd --hidden --exclude .git . "$1"
60+
}
61+
62+
# Use fd to generate the list for directory completion
63+
_fzf_compgen_dir() {
64+
fd --type=d --hidden --exclude .git . "$1"
65+
}
66+
67+
# not yet installed
68+
# source ~/fzf-git.sh/fzf-git.sh
69+
70+
export FZF_CTRL_T_OPTS="--preview 'bat -n --color=always --line-range :500 {}'"
71+
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
72+
73+
# Advanced customization of fzf options via _fzf_comprun function
74+
# - The first argument to the function is the name of the command.
75+
# - You should make sure to pass the rest of the arguments to fzf.
76+
_fzf_comprun() {
77+
local command=$1
78+
shift
79+
80+
case "$command" in
81+
cd) fzf --preview 'eza --tree --color=always {} | head -200' "$@" ;;
82+
export|unset) fzf --preview "eval 'echo \$'{}" "$@" ;;
83+
ssh) fzf --preview 'dig {}' "$@" ;;
84+
*) fzf --preview "bat -n --color=always --line-range :500 {}" "$@" ;;
85+
esac
86+
}
87+
88+
3689
# zoxide
3790
eval "$(zoxide init zsh --cmd cd)"
3891

0 commit comments

Comments
 (0)