Skip to content

Instantly share code, notes, and snippets.

@johan--
Forked from developic/fzf-tab.fish
Created June 19, 2026 04:43
Show Gist options
  • Select an option

  • Save johan--/99dd4c6daf7b1106486e553fbf18d11e to your computer and use it in GitHub Desktop.

Select an option

Save johan--/99dd4c6daf7b1106486e553fbf18d11e to your computer and use it in GitHub Desktop.
fzf-tab.fish
function __fzf_complete
set -l buffer (commandline -b)
set -l token (commandline -ct)
set -l cursor (commandline -C)
set -l trimmed (string sub -s 1 -l $cursor -- "$buffer")
# tools and fallbacks
set -l dir (
if type -q eza
echo "eza -lah --git --icons --color=always"
else
echo "ls -lah"
end
)
set -l file (
if type -q bat
echo "bat --style=numbers --color=always --paging=never --wrap=never"
else
echo "cat"
end
)
set -l preview '
fish -c "
set f {}
if test -d \$f
'"$dir"' \$f
else if test -f \$f
'"$file"' \$f
else if command -q \$f
whatis \$f 2>/dev/null
else if test -e \$f
'"$dir"' \$f
else
echo \$f
end
"
'
# optional: set $fzf_complete_opts for extra fzf flags
set -l selected (
complete --do-complete "$trimmed" |
fzf \
--query="$token" \
--height=~40% \
--layout=reverse \
--ansi \
--preview "$preview" \
--preview-window=down:50%:wrap \
$fzf_complete_opts
)
set -l completion (string split \t -- "$selected")[1]
if test -n "$completion"
commandline -t -- $completion
end
commandline -f repaint
end

fzf-tab

Fish shell completion using fzf (simple, no bullshit, and no need to download any plugin)

Requirements

  • Fish (obviously)
  • fzf
  • eza (optional)
  • bat (optional)

Installation

curl https://gist.githubusercontent.com/developic/643a0384bd911ec09d43850cddf45688/raw/9c1932b9eb25c4bf83a79a29a3473fdd3149de32/fzf-tab.fish -o ~/.config/fish/functions/__fzf_complete.fish && echo 'bind \t __fzf_complete' >> $XDG_CONFIG_HOME/fish/config.fish

reload fish:

source $XDG_CONFIG_HOME/fish/config.fish

Customization

You can set $fzf_complete_opts for extra fzf flags:

set -g fzf_complete_opts --border --cycle --info=inline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment