Modern Command Line tooling
Introduction
A few years ago I ran into the modern-unix repo on GitHub, which collects various modern (i.e built in Rust 🙂) *nix command replacements. Intrigued, I gave them a try and here I am years later and I can confidently say that every tool listed on that repo and this article has been excellent. While most of them are not revolutionary, they're great replacements of classic tools with all the bells and whistles you could ever ask for.
The basics
Let's start at the beginning, which in this case is the shell. I've been a zsh and oh-my-zsh user for ~7 years at this point. I know, I know, zsh isn't exactly new, nor is it a small, underappreciated project, but it still plays a key role in my cmd line setup and I feel like a few plugins are worth highlighting. OMZ has also been around forever at this point and while some people dislike it for various reasons (bloat being a valid point) I've never felt compelled to switch over to any of its alternatives.
The plugins I'd like to highlight are ones that aren't included in OMZ by default, yet I find them indispensible. An exhaustive list of zsh plugins I use can be found over on my GitHub.
zsh-autosuggestions
This plugin basically turns zsh into fish. That's it.
Okay maybe that's not entirely true, because this plugin only brings over fish's auto suggestions to zsh.
fast-syntax-highlighting
Remember when I said that zsh-autosuggestions doesn't entirely turn zsh into fish? Well, when combined with zsh-syntax-highlighting the only thing you're missing from fish is the sane scripting language.
As the name implies, this plugin adds syntax highlighting to the commands you're entering into the shell.
fzf-tab
This plugin replaces the default tab completion of zsh with fzf -- more on fzf later!
forgit
Git command line tooling powered by fzf. For those situations when you really don't want to bring up a GUI or TUI for git operations, but you still want something that approximates a UI.
forgit comes with a fairly large set of git shortcuts that launch inline TUIs like the one in the demo above. For a full list see the forgit documentation.
The game changers
While it's true that most tools in this article are not revolutionary, the following two definitely changed the way I interact with the command line for the better.
fzf
fzf is a general-purpose command-line fuzzy finder. While that works as a definition it doesn't quite tell the story of how insanely versatile fzf is. A non-exhaustive list of use cases I found for fzf:
- Interactively navigate recently visited directories with zoxide
- Search for files in the current directory
- Search for a string in files in the current directory
- Reverse history search
- Shell tab completion
fzf is one of those tools that you really have to try to appreciate how good it really is. Not only is it fast, the integration and extensibility of it is also truly amazing.
zoxide
Zoxide allows you to jump between directories using fuzzy directory matching. Say you're in your home directory and you wanted to immediately jump into a project directory that's 5 directories deep. With zoxide all you need to type is z yourProject
and you're immediately there if you've visited that directory before. As a matter of fact you probably don't even need to type out the project's entire name, z yourProj
will probably work too.
Looking to jump into a specific subdirectory of your project? No problem, just type zi yourProj
, it'll bring up an interactive finder (powered by fzf, of course). Going back to cd
is impossible once you've tried zoxide.
Neat replacements
exa
exa
is a ls
relplacement written in Rust. exa
is ultimately a fancier looking ls
with some neat features such as git and gitignore support, icons via Nerd Fonts and a tree view. I personally just use exa
as a drop-in replacement and have it aliased to ls
and all its zsh variants such as l
and ll
.
While it is slower than ls
, the performance hit has not exactly been noticable for me, though admittedly I haven't had to deal with HDDs or massive directory structures since switching over to exa
.
Installation instructions (note: Windows builds are not currently available from the official website, but you can either build it yourself from source or fetch a binary from the Windows support PR discussion on GitHub)
bat
bat
is described as a "cat(1) clone with syntax highlighting and Git integration." and... it is exactly that.
One thing that's worth mentioning is that bat
comes with an optional set of extensions/plugins that are definitely worth looking into. These extensions can be found here.
delta
Continuing the pattern of "fancy looking Unix command replacement written in Rust", delta
is to diff
as bat
is to cat
. delta
is such a seamless replacement to diff
that I sometimes even forget it exists, until I set up a new system and have to deal with vanilla diff
again.
Not sure how delta
performs on exceedingly large files, but for files that are at most a few thousand lines long it's been perfectly fine (which isn't exactly surprising, but still).
ripgrep
Finally a tool that isn't just "x but fancier, and written in Rust"! Well, the written in Rust part still stands, but ripgrep
is a grep
replacement that is significantly faster than grep
. Don't take my word for it though.
There's not much else to say about ripgrep
, it truly is just a faster and more modern version of grep
and I don't see why one would use grep
on a setup where ripgrep
is available.
fd
fd
is find
's ripgrep
with a more intuitive CLI. The performance gains over find
are significant.
I can only repeat what I wrote about ripgrep
: I don't see why one would use find
if fd
is available.
httpie
httpie
is basically curl
and wget
baked into one, with a very intuitive interface. It's a tool that's very clearly designed around API testing.
If you're a developer that has to interact with web APIs I highly recommend that you give httpie
a try.
btop
btop
is the C++ successor of the bpytop
project and is a much nicer looking replacement of top
/htop
. On top of being nicer looking it also comes with a bunch of themes, support for GPU monitoring and a lot of customization options -- also, not nearly as jumpy as htop
! It works cross-platform too, which I find somewhat surprising.
If you ever wanted to look like you were a part of fsociety or just a hackerman in general, you definitely need to run btop
on your second screen 24/7.
For Windows, see the btop4win project -- the btop4win-lhm build even supports GPU monitoring!
Everything else
Now that we've covered the basics and the replacements, I'll mention a few CLI tools that I use regularly and find very useful.
hyperfine
Ever wanted an easy to use, language/platform agnostic benchmarking command line tool? hyperfine
is exactly that.
Since it is a very convenient tool I find myself using it more and more to benchmark certain algorithm imlementations/framework behaviour before jumping into a profiler.
lazygit
Are you tired of unintuitive git GUIs? Are you fed up with typing out the same git commands over and over again? Are you lazy?
Well good news, if your answer was yes to any of the previous questions, then lazygit
might just be for you! It's a good middle ground between just using the plain old git command and firing up a full blown git GUI. It's fast, intuitive and available on all platforms.
lazydocker
Are you tired of unintuitive Docker GUIs? Are you fed up with typing out the same Docker commands over and over again? Are you lazy?
Well good news, if your answer was yes to any of the previous questions, then lazydocker
might just be for you! It's a good middle ground between just using the plain old docker commands and firing up a full blown docker GUI. It's fast, intuitive and available on all platforms (except Windows I guess, but you're running Docker on WSL anyway).
neovim / LunarVim
I don't think vim
or neovim
need any introductions. Most developers will inevitably interface with vim
at some point during their careers, although it probably won't be a pleasant experience.
Now I'll be the first to admit that I'm not exactly amazing at vim motions. As a matter of fact I'm not even decent at vim! However after setting up neovim with my own keybinds, which-key
and a decent set of plugins I find myself using neovim more and more as a VSCode replacement.
A few weeks ago I also stumbled upon the LunarVim project and decided to give it a try. I have to say it left me extremely impressed -- even though it comes with a fairly large set of plugins, its performance ended up being better than my own custom built, lua-based neovim config!
If you're someone that wants to jump on the neovim
train I suggest you check LunarVim out as a great jumping off point. It comes with sensible defaults, a very nice set of plugins and great performance to boot.