Pick – A Commandline Fuzzy Search Tool For Linux
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.
$ 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:
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/
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.
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”.
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.
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/
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