I am a big fan of quick search. Open dialog, type relevant words, enter and you have desired result. In Windows I switch to Everything (great tool for searching – the best I saw on Windows ATM). Doing programming in different languages, using configuration files in different formats for different platforms and then remembering, where you put it, it is very hard task to achieve. Even with having only few places to search for, it is still tedious operation. Usually the challenge is to remember the file name with specific content. Did I put that piece of code in Dockerfile or did I used Dockerfilewithregistry or did I create notes for that aka Dockefilenotes, etc.
I, for example, remember using specific naming for configuration in files or maybe specific code block, but almost never the name of the file. Can you imagine, how much index.html files can be, if you have multiple projects on your machine? When I see the file or name, I do remember, but to get to that point, it can take quite some time and jumping around the file manager (if you use frequent folders, check out autojump).
GUI or Terminal?
Terminal has powerful built-in features – locate / find commands – which (if mastered correctly), are fast and can do wonders (and you can use pipes to do even more).
I am a big fan of doing stuff in the terminal, but when developing, I want to quickly jump from my favorite IDE and find stuff or execute command on the fly without switching to terminal and writing long commands to get back narrowed search result. Sure, terminal popups like Guake really helps, but when switching, I only want to execute specific tasks with adjusted GUI. If I need to search for an app, I don’t need the whole start menu, just textbox, type name, enter and my app is running. I already found my favorite application launcher to satisfy those requirements – Ulauncher (nifty one textbox with powerful options to configure). Ulauncher is great and it would be great to use just one tool to search through files as well, but it lacks the ability to search files.
If you ask yourself, why not just leverage built-in file managers, the answer is simple – I need to search inside files for content specific results. Files in Linux Mint (File manager) don’t have the ability to do that. Probably there are some kind of Linux File managers available and you can change the whole file manager with another, but I like built-in manager and works for me.
After researching a bit, I stumble upon this blog post and I decided to give CatFish a try.
CatFish is a powerful search GUI tool with simple interface to give you an ability to search not just through files, but also content of the files. Sure, operation is a little bit slower, but still faster than doing this manually.
Installation is very simple. You search for it inside your software center. If you don’t find it there, it can be installed via terminal as well.
sudo apt install catfish
I do recommend checking out the code as well (written in GTK+ and Python) – you can see inter-connection with Zeitgest and execution of terminal commands to get back the results quickly and efficient.
After opening, I do recommend doing database update to get latest and greatest file index. You can find the update part in the preferences section.
Select Gear icon and choose menu option Refresh search index.
Click on the Unlock button. You will need sudo privileges in order to continue.
After few seconds (depends on the disk size) you should see the finished result.
You are now ready to do some searching exercises.
Let’s find that file with that specific content
The most appealing ability in CatFish is the option to search through content in files. If you know, where to look, this can be fast. if you need to search through large disk, I can be slower. In that case, it is good to set the scope to specific folder.
Next thing, we need to set the option to search through files. Click gear button and enable Search file contents.
Now we are ready to search for some files. For example – I remember, that i have commands cheat file for Kubernetes somewhere on the system. And I remember, that there is command to get all pods back. If I enter pod, I can easily get the result inside kubectl commands.txt file on the system. If you double click on the file, it will open it in default editor.
Let’s create new file in different folder (txt file) and put in the text PODS (with upper case) and repeat the search. We got the result, even though CAPS was used.
If I want, for example, to search through some specific content and with specific file extension type, we can narrow down result with using multiple query string. Let’s create some test files with some content data. I created simple bash script snippet to serve our test purpose (in terminal you can use use wget http://data.azuredemos.net/public/create-file-and-add-data.txt, create nano files.sh and don’t forget to add execute permissions to the file with chmod, when finished).
After you run that script ./files.sh, you will see 6 files, 3 with txt and 3 with yaml file extension with some random data. Check values as well (cat file1.txt file1.yaml)
Let’s first search for testing as everything has a test inside.
Great, everything was found as I wanted. Let us search for number 5.
Now let us only search for yaml and 5.
As you can see, file.txt is still there. To narrow down the results, we need to specify extension type. In short, search only yaml files. To do that, open gear icon and select sidebar or press F9. Choose Other and type yaml as extension.
After using Catfish for a while, it is quite a handy tool. I still miss regex support directly in the textbox and hotkeys as in ULauncher, but for majority of my searches, it does the job pretty well. You can always fine tune the query with additional parameters (sidebar) and available options out of the box without the need to open file manager and traverse down the tree.
I didn’t try ANGRYSearch or SearchMonkey – this looks like really powerful tool to leverage regex to find the files. I’ll try to stick with one solution for a while and then, if the challenges are too large, try to find a new tool/application to address those issues.
As I am mainly searching for code patterns and configuration files / commands etc., on my PC, this is a nifty tool that can save time and I will add it to my toolbox going forward.