Photo by Clay Banks on Unsplash
Optimize Your Workflow: 3 Command Line Tools You Should Try Today
Improve your developer experience by using ripgrep, jq and bat
As a developer, I spend a lot of time thinking about how to improve my workflows.
Sometimes I build a small tool to solve a problem I have. I might spend an hour building something if it'll save me time on a daily, weekly or monthly basis. That time adds up and can make a difference in the long run.
Other times, I look to see if the tools I'm using are really the best tool for the job.
In an effort to maximize my efficiency, I spend a lot of my time in the command line. I even dropped bigger IDEs in favor of neovim. It's a great feeling to be able to be so productive without having to leave the keyboard.
To that end I wanted to talk about three command line tools which I use on a daily basis:
1. ripgrep
Use ripgrep if you like speed, filtering by default, fewer bugs and Unicode support.
ripgrep is a text search utility. If you immediately thought of grep
then that's exactly right. ripgrep
is an alternative to the standard grep
utility. It's a feature rich tool that's written in rust so it optimizes for speed.
Here are a few highlights:
- Defaults to recursive directory search
- Supports searching by file type
- Automatically ignores files listed in
.gitignore
and other ignore files - Supports searching files that are compressed in a common format
For the most part, ripgrep
serves a similar use case as grep
, but from what I've seen it's much faster in day to day use. I even run it inside of neovim to do project wide text searches without having to close the editor.
2. jq
jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text.
jq is a command line json processor.
Why is this useful?
If you're working on any kind of API, you're going to want to test that things are working. Sometimes you'll reach for a more robust solution like Postman. Other times, you need something quick so you'll rely on a curl
command.
When you use curl
the json
that comes back is typically unreadable. It's not formatted or highlighted so it can be difficult to understand. Instead, if you pipe the json results to jq
you can easily see the structure of the json in a nice format.
jq
also supports filtering. This makes it easy to dig into large json payloads so you can find the parts that you're most interested in. jq
also makes it easy to run conditional logic to test the data that's coming back.
3. bat
A cat(1) clone with wings.
bat is a cat
alternative.
It's used to quickly display the contents of a file. What makes it unique is that it supports syntax highlighting based on the filetype. bat
can also be integrated with many other tools like git. When used with git, diffs are properly syntax highlighted when run in the command line.
This can make the review process much easier.
bat
might not speed up your workflow as much as the other tools, but I find that it's more enjoyable to use than cat
.
Sometimes that's enough.
Conclusion
It's important to make sure the tools you're using everyday fit your needs. It's also important that you enjoy using them. I've been using these three tools daily for a while now and they've made my workflow much better.