Home Command line utilities Pick – A Commandline Fuzzy Search Tool For Linux

Pick – A Commandline Fuzzy Search Tool For Linux

By sk
Published: Last Updated on 1.1K views

Today, we will be discussing about an Interesting commandline utility called "Pick". It allows users to select from a set of choices using an ncurses(3X) interface with fuzzy search functionality. The Pick utility can be helpful in certain situations where you want to search for a folder or file that contains a non-English characters in their name. You don't have to learn how to type the non-english characters. Using Pick, you can easily search them, select them and view or cd into them easily. You don't even have to type any characters to search a file or folder. It's good for those working with large pile of directories and files.

Installing Pick

For Arch Linux and its derivatives, Pick is available in AUR. So, the Arch users can install it using AUR helper tools such as Yay.

$ yay -S pick

The Debian, Ubuntu, Linux Mint users run the following command to install Pick.

$ sudo apt-get install pick

For other distributions, download the latest release from here and follow the below instructions to install Pick. As of writing this guide, the latest version was 1.9.0.

$ wget https://github.com/calleerlandsson/pick/releases/download/v1.9.0/pick-1.9.0.tar.gz
$ tar -zxvf pick-1.9.0.tar.gz
$ cd pick-1.9.0/

Configure it using command:

$ ./configure

Finally, build and install pick:

$ make
$ sudo make install

How to use Pick, the Commandline Fuzzy Search Tool For Linux

You can make your commandline life much easier by combining Pick with other commands. I will show some examples, so you can understand how it works.

Let me create a stack of directories.

$ mkdir -p abcd/efgh/ijkl/mnop/qrst/uvwx/yz/

Now, you want to go the directory /ijkl/ directory. You have two choice. You can either use cd command like below:

$ cd abcd/efgh/ijkl/

Or, create a shortcut or an alias to that directory, so you can switch to the directory in no time.

Alternatively, just use "pick" command to switch a particular directory more easily. Have a look at the below example.

$ cd $(find . -type d | pick)

This command will list all directories and its sub-directories in the current working directory, so you can just select any directory you'd like to cd into using Up/Down arrows, and hit ENTER key.

Sample output:

List directories and sub-directories with Pick command

List directories and sub-directories with Pick command

Also, it will suggest the directories or files that contains a specific letters as you type them. For example, the following output shows the list of suggestions when I type "or".

Directory or File suggestion with Pick command

Directory or File suggestion with Pick command

It's just an example. You can use "pick" command along with other commands as well.

Here is an another example.

$ find -type f | pick | xargs less

This command will allow you to select any file in the current directory to view in less.

Combine Pick command with less and find commands

Combine Pick command with less and find commands

Care to learn another example? Here you go. The following command will allow you to select individual files or folders in the current directory you want to move to any destination of your choice, for example /home/sk/ostechnix.

$ mv "$(find . -maxdepth 1 |pick)" /home/sk/ostechnix/
Combine pick command with mv and find commands

Combine pick command with mv and find commands

Choose the file(s) by using Up/Down arrows and hit ENTER to move them to /home/sk/ostechnix/ directory.

As you see in the above output, I have moved the folder called "abcd" to "ostechnix" directory.

The use cases are unlimited. There is also a plugin called pick.vim for Vim editor to make your searches much easier inside Vim editor.

For more details, refer man pages.

$ man pick

Resource:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More