5 Linux Utilities to Improve Your Programming Workflow in 2022
Last updated on 31 August 2022
Working as a Software Developer, there are always new tools and frameworks coming out that can completely change your workflows – for the better (or worse?).
Either way, there is always the possibility to optimize how you do things day-to-day.
This article contains some Linux utilities that have recently replaced my overused and under-productive daily programming workflow.
You will learn about those utilities and how they are a better alternative to their counterparts.
Let's begin.
Better reverse history with Mcfly
Do you relentlessly hit up arrow on the terminal until you get the command you ran previously? I've been there. I didn't know I could optimize this, so I was using it religiously for quite some time.
Then I got introduced to ctrl + r
. It allows you to search through your command history and has wildcard search. Wow.
Results? My finger tapping exercise was over from the first day. Again, I thought this must be the peak DX for such a small utility. I was so wrong.
So what? Well, there's a better ctrl-r
for you. Introducing Mcfly 🦋.
In addition to the regular ctrl+r
feature, it has some extra niceness:
- The suggestions are customized using a neural network which considers your current working directory and recently executed commands.
- It tracks exit status of commands (you probably don't want to run a failed command again), timestamp, and other useful information.
- You can use
%
as a wildcard to match multiple characters.
Here are the suggestions I got for "dev" on two different repositories, based on my shell history:
You can install Mcfly from here.
Cheat sheets for the win
Who loves reading man pages? I don’t. When I’m struggling with a command, the last thing I want to read is a man page. Not because it's not helpful, but it is overwhelming.
I often just need quick examples that I can grab on the go and use. When I found TLDR pages, I was the happiest person. Now with Cheat (sheets), I’m even happier.
Cheat gives you access to the cheatsheets for potentially every command you will ever need — only examples, without the encyclopedia.
If you do not want to install the utility, you can get the cheatsheet using CURL like this:
1curl cheat.sh/uptime
So instead of installing the cheatsheets on your machine, you are fetching the information for only the command you need. You can visit cheat.sh and use it on your browser as well.
Here is how the output of the above command looks:
You will find a lot of examples in the codebase.
How to Use Git Open
I often need to open the GitHub repository of the project I'm working on in the browser. It may be to check for comment updates on the Pull Request I raised, change repository settings, or just about anything that will require the GitHub repository page.
Well, we have a utility even for this!
Running git open
will open your current working repository on your browser. By default, it opens the remote page for the branch you are on. You can even go ahead and create an alias for the commands to avoid typing the whole thing.
Here are some of alias ideas for you:
zshrc file
1alias go="git open"2alias blog="git open https://github.com/<username>/blog <branch>"
Check out Git Open on Github here.
How to Use Bat
We have all done cat
, right? Bat is just that but has syntax highlighting, nice formatting and styling options, and git diff support. It is very versatile, integrates easily with other tools, and provides custom theming options as well.
Let's a take a look. This is our express server file using cat
:
The above output has no syntax highlighting which decreases the readability of the code. Let's do the same using bat
:
This is clearly more readable. It has the appropriate syntax highlighting automatically applied (without any config), provides the file name, and line numbers.
Feel free to start using it here.
How to Use Jq
Jq is a command-line processor for JSON. You can slice and dice your JSON, perform projection to only show certain fields, and extract only the required information from a (huge) JSON. No more overwhelming the terminal output.
Sample input array
1[2 {"value": 1, "rating": 2 },3 {"value": 2, "rating": 4 },4 {"value": 3, "rating": 5 }5]
Accessing a key from an array looks like this:
1jq '.[0] | { value }'
We are asking for the first element in the array and projecting only the value
field:
1{2 "value": 13}
To learn more, head over to their official tutorial.
They also have a handy online playground. I have created a snippet here. Feel free to tweak it and play around.
You can even take it a step further with jid. It is an interactive JSON digger that leverages Jq. It provides you very convenient suggestions and an auto-complete feature.
Conclusion
These were some of the utilities that expanded the horizon for me and made me realise that there is always a better way to do things. You just need to keep Googling. Starting with "how to do X" and "better alternatives to X".
I use these utilities quite often in my daily programming workflow. I hope at least one of them will be useful to you.
I would love to know what utilities are crucial to your daily workflow – do you use any of the ones mentioned in this article?