fifc ๐Ÿ 

July 14, 2026 ยท View on GitHub

fifc ๐Ÿ 

fish fzf completions

CI

fifc brings fzf powers on top of fish completion engine and allows customizable completion rules

gif usage

โœ… Requirements

โœจ Features

  • Preview/open any file: text, image, gif, pdf, archive, binary (using external tools)
  • Preview/open command's man page
  • Preview/open function definitions
  • Preview/open full option description when completing commands
  • Recursively search for files and folders when completing paths (using fd)
  • Preview directory content
  • Preview process trees (using procs)
  • Modular: easily add your own completion rules
  • Properly handle paths with spaces (needs fish 3.4+)

๐Ÿš€ Install

fisher install gazorby/fifc

๐Ÿ”ง Usage

You only need to set one setting after install:

set -Ux fifc_editor <your-favorite-editor>

And enjoy built-in completions!

By default fifc override tab, but you can assign another keybinding:

# Bind fzf completions to ctrl-x
set -U fifc_keybinding \cx

fifc will also by default use rm to remove temporary files, this can changed:

# Use trash instead of rm
set -U fifc_rm_cmd trash

To append a custom fzf command, for example to disable the --exact flag and increase the fuzziness:

set -U fifc_custom_fzf_opts +e

Inside the fzf picker, fifc binds a few keys to make navigation and multi-selection feel like completion:

KeyAction
tabMove to the next candidate
shift-tabMove to the previous candidate
ctrl-spaceSelect the current candidate and move to the next one
ctrl-oRun the open command on the current candidate (see fifc_open_keybinding)

fifc uses fzf --multi, so selecting several candidates with ctrl-space inserts them all at once.

You can override or extend these binds through fifc_custom_fzf_opts (later --bind values win).

fifc can use modern tools if available:

PreferFallback toUsed forCustom options
batcatPreview files$fifc_bat_opts
chafafilePreview images, gif, pdf etc$fifc_chafa_opts
hexylfilePreview binaries$fifc_hexyl_opts
fdfindComplete paths$fifc_fd_opts
ezalsPreview directories$fifc_eza_opts
ripgreppcregrepSearch options in man pages-
procspsComplete processes and preview their tree$fifc_procs_opts
broot-Explore directory trees$fifc_broot_opts

Custom options can be added for any of the commands used by fifc using the variable mentioned in the above table.

Example:

Show line number when previewing files:

  • set -U fifc_bat_opts --style=numbers

Show hidden file by default:

  • set -U fifc_fd_opts --hidden

โš ๏ธ Don't use quotes in variables, set them as a list: set -U fifc_eza_opts --icons --tree

๐Ÿ› ๏ธ Write your own rules

Custom rules can easily be added using the fifc command. Actually, all builtin rules are added this way: see conf.d/fifc.fish

See fifc -h for more details.

Basically, a rule allows you to trigger some commands based on specific conditions.

A condition can be either:

  • A regex that must match commandline before the cursor position
  • An arbitrary command that must exit with a non-zero status

If conditions are met, you can bind custom commands:

  • preview: Command used for fzf preview
  • source: Command that feeds fzf input
  • open: Command binded to fifc_open_keybinding (defaults to ctrl-o)

All commands have access to the following variable describing the completion context:

VariableDescriptionCommand availability
fifc_candidateCurrently selected item in fzfall except source
fifc_commandlineCommandline part before the cursor positionall
fifc_tokenLast token from the commandlineall
fifc_groupGroup to which fish suggestions belong (possible values: directories, files, options or processes)all
fifc_extractedExtracted string from the currently selected item using the extracted regex, if anyall except source
fifc_queryfzf query. On source command, it is the initial fzf query (passed through --query option)all

fifc_group values

fifc test completion items to set fifc_group with the following conditions:

GroupCondition
directoriesAll completion items are directories
filesItems can be either files or directories
optionsAll items match the following regex: \h+\-+\h*$
processesAll items match the following regex ^[0-9]+$ (list of PID)

Matching order

By default, fifc evaluate all rules in the order in which they have been defined and stops at the first where all conditions are met. It does this each time it has to resolve source, preview and open commands.

Take the following scenario:

# Rule 1
fifc -n 'test "$fifc_group" = files' -p 'bat $fifc_candidate'
# Rule 2
fifc -n 'string match "*.json" "$fifc_candidate"' -p 'bat -l json $fifc_candidate'

When completing path, $fifc_group will be set to "files" so the first rule will always be valid in that case, and the second one will never be reached.

Another example:

# Rule 1
fifc --condition 'test "$fifc_group" = files' --preview 'bat $fifc_candidate'
# Rule 2
fifc --condition 'test "$fifc_group" = files' --source 'fd . --color=always --hidden $HOME'

Here, even if both rules have the same conditions, they won't interfere because fifc has to resolve source commands before the preview commands, so order doesn't matter in this case.

Override builtin rules

If you want to write your own rule based on the same conditions as one of the built-in ones, you can use fifc --order option. It tells fifc to evaluate the rule in a predefined order, so you can set it to 1 to make sure it will be evaluated first.

When omitting the --order, the rule will be declared unordered and will be evaluated after all other ordered rules, and all other unordered rules defined before.

All built-in rules are unordered.

Examples

Here is how the built-in rule for file preview/open is implemented:

fifc \
    # If selected item is a file
    -n 'test -f "$fifc_candidate"' \
    # bind `_fifc_preview_file` to preview command
    -p _fifc_preview_file \
    # and `_fifc_preview_file` when pressing ctrl-o
    -o _fifc_open_file

Interactively search packages in archlinux:

fifc \
    -r '^(pacman|paru)(\\h*\\-S)?\\h+' \
    -s 'pacman --color=always -Ss "$fifc_token" | string match -r \'^[^\\h+].*\'' \
    -e '.*/(.*?)\\h.*' \
    -f "--query ''" \
    -p 'pacman -Si "$fifc_extracted"'

gif usage

Search patterns in files and preview matches when commandline starts with **<pattern> (using ripgrep and batgrep):

fifc \
    -r '.*\*{2}.*' \
    -s 'rg --hidden -l --no-messages (string match -r -g \'.*\*{2}(.*)\' "$fifc_commandline")' \
    -p 'batgrep --color --paging=never (string match -r -g \'.*\*{2}(.*)\' "$fifc_commandline") "$fifc_candidate"' \
    -f "--query ''" \
    -o 'batgrep --color (string match -r -g \'.*\*{2}(.*)\' "$fifc_commandline") "$fifc_candidate" | less -R' \
    -O 1

gif usage

โค๏ธ Credits

Thanks PatrickF1 (and collaborators!), for the great fzf.fish plugin which inspired me for the command-based configuration, and from which I copied the ci workflow.

๐Ÿ“ License

MIT