Quantcast
Channel: geekoverdose
Viewing all articles
Browse latest Browse all 70

FZF: usage and installation

$
0
0

FZF, the fuzzy command-line finder, is a really useful small tool for your command line that makes it easier to:

  1. quickly search your shell’s command history
  2. quickly find+select files/folders to pass to a command
  3. quickly find a directory and change into it

I’d argue that once you got used to FZF you’ll quite likely find the regular Ctrl+R command history search annoying and might not want to miss FZF anymore.

Usage

The FZF readme does a good job in concisely explaining the FZF usage. Below I’m providing a bit more info around some details (e.g. which keys to press for selections) that might be non-obvious in the beginning.

1. Search command history

Press Ctrl+R to open a searchable list with commands in your shell’s command history. Search for and select the command you want and press Enter to paste it into your shell. This replaces whatever else you had typed in your shell before.

Pressing Crtl+R when the searchable list is already open switches the order of commands in the list between chronological and most relevant for what you typed to far.

2. Search and select files and folders

Press Ctrl+T to open a searchable list of files and folders that are located (recursively) under the current working directory. Search for any files and folder that you want to select and mark them as selected by pressing Tab. Once you selected everything you want to be selected, press Enter to paste the relative paths of the selected files and folders (relative to your current working directory) into your shell at the position of the cursor. This does not overwrite what you wrote before, so you can use this to select (multiple) paths that you want to pass to a command that you typed before.

You can modify your search term in between selecting files and folders, and selected elements can be in different (sub)folders relative to your current working directory.

3. Search for a directory and change into it

Press Alt+C to open a searchable list of folders that are located (recursively) under the current working directory. Search for the folder that you want to change into, select it, and press Enter.

This does not overwrite what you had typed in your shell before, so you can also use it in between typing a command and executing it.

Installation and keybindings

Luckily, nowadays FZF is fairly easy to install on most Linux distributions. The FZF repo maintains a list of installation methods, including via different package managers.

Note that besides installing FZF, depending on your shell, you might also need to manually enable FZF keybindings for the keybindings that are mentioned above to work.

Some noteworthy examples:

Arch Linux installation

See the Arch wiki fzf article for further options.

[sudo] pacman -Syu fzf

Ubuntu/Debian installation

See the Ubuntu and Debian fzf repo pages for further options.

[sudo] apt-get install fzf

Fish shell keybindings

If you use the fish shell, then after installing FZF you also need to manually enable the FZF keybindings. For an example for Arch Linux: see the Arch wiki fzf article.


Viewing all articles
Browse latest Browse all 70

Latest Images

Trending Articles





Latest Images