Skip to content

Instantly share code, notes, and snippets.

@developic
Last active August 7, 2026 05:59
Show Gist options
  • Select an option

  • Save developic/643a0384bd911ec09d43850cddf45688 to your computer and use it in GitHub Desktop.

Select an option

Save developic/643a0384bd911ec09d43850cddf45688 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")
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
"
'
set -l fzf_flags \
--query="$token" \
--height=~40% \
--layout=reverse \
--ansi \
--preview="$preview" \
--preview-window=down:50%:wrap
set -l matches (complete --do-complete "$trimmed")
set -l selected
if test (count $matches) -eq 1
set selected $matches[1]
else
set selected (
printf '%s\n' $matches |
fzf $fzf_flags $fzf_complete_opts
)
end
set -l completion (string split \t -- "$selected")[1]
if test -n "$completion"
commandline -t -- (string replace -a ' ' '\ ' -- "$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

Install with Fisher:

fisher install developic/fzf-tab

Customization

You can set $fzf_complete_opts for extra fzf flags:

set -g fzf_complete_opts --border --cycle --info=inline
@developic

Copy link
Copy Markdown
Author
image image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment