Fzf: Difference between revisions

From NixOS Wiki
imported>Sheepfleece
No edit summary
imported>Dmarcoux
Add commands to source completion functions for bash and zsh
Line 12: Line 12:
<syntaxhighlight lang="bash">if command -v fzf-share >/dev/null; then
<syntaxhighlight lang="bash">if command -v fzf-share >/dev/null; then
   source "$(fzf-share)/key-bindings.bash"
   source "$(fzf-share)/key-bindings.bash"
  source "$(fzf-share)/completion.bash"
fi</syntaxhighlight>
fi</syntaxhighlight>


Line 20: Line 21:
if [ -n "${commands[fzf-share]}" ]; then
if [ -n "${commands[fzf-share]}" ]; then
   source "$(fzf-share)/key-bindings.zsh"
   source "$(fzf-share)/key-bindings.zsh"
  source "$(fzf-share)/completion.zsh"
fi
fi
</syntaxhighlight>
</syntaxhighlight>

Revision as of 15:57, 18 April 2020

fzf is a general-purpose command-line fuzzy finder.

Shell extensions

fzf provides additional key bindings (CTRL-T, CTRL-R, and ALT-C) for shells

First install fzf in your profile, then use one of the following methods:

bash

To enable fzf in bash add the following line to .bashrc

if command -v fzf-share >/dev/null; then
  source "$(fzf-share)/key-bindings.bash"
  source "$(fzf-share)/completion.bash"
fi

zsh

To enable fzf in zsh add the following line to .zshrc

if [ -n "${commands[fzf-share]}" ]; then
  source "$(fzf-share)/key-bindings.zsh"
  source "$(fzf-share)/completion.zsh"
fi

fish

To enable fzf in fish, add the following to $HOME/.config/fish/functions/fish_user_key_bindings.fish

function fish_user_key_bindings
  if command -s fzf-share >/dev/null
    source (fzf-share)/key-bindings.fish
  end

  fzf_key_bindings
end