FZF: The Ultimate Linux Productivity Tool

📆 · ⏳ 3 min read · ·

Introduction

As a Linux user, you’re likely familiar with the power and flexibility of the command-line interface (CLI). But even the most experienced users can find themselves bogged down by long lists of output or hard-to-remember command syntax.

That’s where fzf comes in - this powerful tool streamlines many common CLI tasks, making your Linux experience more efficient and enjoyable.

What is fzf?

Fzf ↗️ is a command-line fuzzy finder that can help you quickly search and select files, processes, command history, and more. It’s lightweight, fast, and highly customizable, making it a popular tool among Linux power users.

Fzf works by filtering a list of items based on a query, allowing you to quickly narrow down and select the desired item.

Install it by following the instructions mentioned here ↗️

How to Use fzf

Here are some examples of how to use fzf in your everyday Linux workflow:

Searching for Files

To search for files using fzf, simply navigate to the directory you want to search and type the following command:

Terminal window
ls | fzf

This will display a fuzzy-searchable list of files in the current directory, allowing you to quickly select the file you’re looking for.

Selecting a Process to Kill

To kill a process using fzf, type the following command:

Terminal window
ps aux | fzf | awk '{print $2}' | xargs kill

This will display a list of running processes, which you can filter using fzf. Once you’ve selected the process you want to kill, fzf will output the process ID, which is then piped to the kill command via xargs.

Searching Command History

To search your command history using fzf, simply type:

Terminal window
history | fzf

This will display a searchable list of your recent command history, allowing you to quickly recall and execute past commands.

Checkout to a Git branch

To search your git branches easily with fzf and checkout to it, simply type:

Terminal window
git branch --all | fzf | xargs git checkout

This will display a searchable list of your git branches, allowing you to quickly checkout to the selected branch.

Opening a file in Vim

You can use fzf to open any file in Vim, simply type:

Terminal window
vim $(fzf --preview 'echo {}')

Selecting and copying text from a file

You can use fzf to select a file and then select and copy text from that file by typing:

Terminal window
find . -type f | fzf --preview 'cat {}' | xargs -r awk '{print}' | xclip -selection clipboard

Make sure you have xclip ↗️ installed before using it.

Conclusion

Fzf is a versatile and powerful tool that can help you streamline many common CLI tasks, making your Linux experience more efficient and enjoyable. By using fzf, you can save time and reduce frustration, allowing you to focus on the work that really matters.

With its intuitive interface and customizable features, fzf is a must-have tool for any Linux power user. So why not give it a try and see how it can take your productivity to the next level?

You may also like

  • HTTPS with self-signed certificates for your Homelab services

    In this article we will deep dive into understanding how we can setup HTTPS with self-signed certificates for our Homelab services.This is often required when you are running your own services and you want to access them over HTTPS.

  • Setup Shareable Drive with Samba in Linux

    In this article we will setup a shareable drive in Linux with SMB. We will learn how to setup the share directory using Samba on server and how to mount it on client.

  • Setup Shareable Drive with NFS in Linux

    In this article we will learn how to setup a shareable drive with NFS in Linux. We will see the steps to setup NFS server and mount the drive on a client machine.