Skip to content

Instantly share code, notes, and snippets.

@azet
Last active April 15, 2026 17:33
Show Gist options
  • Select an option

  • Save azet/ad99ad581b5f18e34b681a13c1da4bdf to your computer and use it in GitHub Desktop.

Select an option

Save azet/ad99ad581b5f18e34b681a13c1da4bdf to your computer and use it in GitHub Desktop.
fuzzy finding, copying and opening of dirs and files with fzf - to be added to bashrc or zshrc (F2 button specific to OSX - pbcopy and open can be easily changed)
# fzf
## fzf interation
__fzf_path=($(whereis -b fzf))
[[ -f ${__fzf_path[2]} ]] && {
source <(${__fzf_path[2]} --zsh)
}
## fzf completion options XXX/TODO(azet): needs to be tested
export FZF_COMPLETION_AUTO_COMMON_PREFIX=true
#export FZF_COMPLETION_AUTO_COMMON_PREFIX_PART=true
## fzf default opts
export FZF_DEFAULT_OPTS="--layout=reverse --info=inline --border --margin=1 --padding=1 --style full --preview 'fzf-preview.sh {}' --bind 'focus:transform-header:file --brief {}'"
## fzf & tmux
[[ -z "${TMUX}" ]] || alias fzf='fzf-tmux -x5 -h "55%" -w "25%" --padding=1 --border=rounded --margin=0,1 --info=right --separator== --scrollbar=↓ --select-1 --exit-0'
## find fzf supported dir/file based
[[ ! -z "${TMUX}" ]] && \
alias fzind="find * &>/dev/null | fzf-tmux --prompt 'All> ' --reverse --border --padding 5 --margin 1 \
--header 'CTRL-D: Directories / CTRL-F: Files' \
--bind 'ctrl-d:change-prompt(Directories> )+reload(find * -type d)' \
--bind 'ctrl-f:change-prompt(Files> )+reload(find * -type f)' --multi --bind 'enter:become(open {+})' \
--bind 'f1:execute(vim {}),f2:execute-silent(cat {} | pbcopy)+abort'" \ # F1 executes current selection in vim, F2 copies contents to clipboard (OSX)
|| \
alias fzind="find * &>/dev/null | fzf --prompt 'All> ' --reverse --padding 2 --margin 5 \
--border=rounded --separator== --scrollbar=↓ \
--header-border horizontal \
--border-label-pos 2 \
--color 'label:blue' \
--header 'CTRL-D: Directories / CTRL-F: Files' \
--bind 'ctrl-d:change-prompt(Directories> )+reload(find * -type d)' \
--bind 'ctrl-f:change-prompt(Files> )+reload(find * -type f)' --multi --bind 'enter:become(open {+})' \
--bind 'f1:execute(vim {}),f2:execute-silent(cat {} | pbcopy)+abort'"
# ...
# see also: https://github.com/azet/dotfiles (snippet from .zshrc.local)
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment