fzf - a fuzzy finder for the command line

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
step
Posts: 510
Joined: Thu Aug 13, 2020 9:55 am
Has thanked: 50 times
Been thanked: 179 times
Contact:

fzf - a fuzzy finder for the command line

Post by step »

Fzf is a popular interactive fuzzy finder for the command line. You can use it instead of grep when you have an approximate idea of the terms you are looking for. With fzf you can refine the terms while the search takes place. For example, find | grep 'some-exact-file-name' is rather inflexible if you can't remember the file name exactly. On the other hand find | fzf allows you to explore the output of find interactively and is forgiving about mispelling the search terms.

Fatdog64-810 introduced fzf pre-installed. Try find | fzf in a terminal window now.

Fzf provides optional key bindings that enhance the shell experience. For instance, in a terminal window running bash you can press Ctrl+T to run find | fzf in the current directory. Ctrl+R gives you fuzzy shell history, and "/path/** TAB" gives you fuzzy path completion. However, Fatdog64 doesn't install key bindings by default leaving it to you to decide whether you want to change your habits.

To enable shell key bindings for your current shell (sh, bash, fish, zsh) run the following shell commands:

Code: Select all

    sed -i -e 's/download() *{/& return 0;/' /usr/share/fzf/install &&
    (cd /usr && sh share/fzf/install --update-rc)

The install script will create file ~/.fzf.bash, and output more instructions. If "bash" is your default shell you shouldn't need to do anything else. Key bindings will be loaded the next time you start a bash shell.

Do not run the uninstall script. To uninstall the new key bindings simply remove file ~/.fzf.bash.

If "sh" is your default shell you will need to make "sh" source "~/.fzf.bash". The following command does that permanently.

Code: Select all

    echo 'case $- in (*i*) . $HOME/.bashrc;; esac' >> $HOME/.shinit

Note that while "sh" is largely compatible with "bash", "sh" remains a subset of "bash". Therefore not all key bindings that work in "bash" can work in "sh"; but you will still get some benefit from the key bindings.

If zsh or fish is your default shell the install script will install file "\~/.fzf.zsh" or "~/.fzf.fish" respectively.

FAQ

Q When I press Ctrl+R (shell history) the shell complains that perl isn't installed.

A This happens with the fzf version (0.39.0) pre-installed in Fatdog64 901. Note that Fatdog64 902 - when released - will include a newer fzf version that doesn't require perl. Until then you can either install the perl package or load the Fatdog64 devx SFS, which includes the perl command.

Post Reply

Return to “Software”