Matthew Tyson
Contributing writer

9 command-line jewels for your developer toolkit

how-to
05 Jun 20248 mins
Software Development

For developers who love the CLI and those who don't, here are nine command-line tools that'll make your workdays easier and might even spark joy.

Treasure chest on a sandy beach.
Credit: New Africa/Shutterstock

Some developers use the command line because we have no choice; others use it because we kind of love it. Either way, you know who you are. Whether you are a lover of the CLI or just using it for work, here are nine command-line tools that will help make you more efficient, on or off the job.

9 CLI tools to use for better developer experience

  • tldr
  • ngrok
  • screen
  • sdkman and nvm
  • fzf
  • exa
  • bat
  • nethack

Tldr

I won’t wax poetic here about that peculiar magic of the Unix shell. Sometimes you just need to get work done, and sometimes you need to read the manual first. Traditionally, Unix docs (the man-pages, or manual) are a two-edged sword: the information is there, somewhere. Finding the documentation you need in a sea of detail is a daunting task.

To get the official manual on a command line, you type:


$ man <command-name>

The limitations of the man page are its dense verbosity and that it sometimes doesn’t have current information for newer tools. Instead, you can use tldr, a more succinct and up-to-date take on the man command:


$ tldr <command-name>
Matthew Tyson

Learn more about tldr: https://tldr.sh.

If you have npm installed, an easy way to install tldr is:


npm install -g tldr

Ngrok

Once you have tldr installed, you can use it to explore many other fine commands. Here’s a good one:


$ tldr ngrok
Reverse proxy that creates a secure tunnel from a public endpoint to a locally running web service.

Ngrok is an interesting animal because it is both a for-profit company and a free-to-use command-line tool. But I’ve never found the commercial side to interfere with ngrok‘s utility.

Ngrok gives you a zero-stress way to access a development machine from a remote browser. But it does more than just that.

I regularly use ngrok to develop on the cloud and view the results in my browser. It also provides a dead-simple way to expose your running service over HTTPS without messing with any security infrastructure. (Say you are building a service worker and it requires HTTPS; now you can just spin up ngrok and there’s your secure context.)

For example, let’s expose HTTP port 8080 to the world:


$ ngrok http 8080

Ngrok returns the following:


https://f951-34-67-117-59.ngrok-free.app -> <a href="https://localhost:8080" rel="nofollow">https://localhost:8080</a>

Now, anyone can go to https://f951-34-67-117-59.ngrok-free.app and see what’s there. (You won’t find anything there now because I just killed off the process.)

Matthew Tyson

Install Ngrok: https://ngrok.com/download.

Screen

Ah yes, screen. This command-line tool sits between the limited simplicity of backgrounding a process with bg and the more complex capabilities of systemctl. With screen, you can take a shell session and put it aside with or without a running process, then bring it back just like you left it. If you log out of the session that spawned the screen, it will still be there when you return.


$ tldr screen 
Hold a session open on a remote server. Manage multiple windows with a single SSH connection.

Let’s say we’re launching ngrok to access a web app we’re working on remotely—a perfect use case for ngrok. We can start the ngrok process, then leave it running in screen and go do some coding. Ngrok keeps running all the while, and anytime we need to, we can drop into screen to check the HTTPS address or stop ngrok.

We can handle this by doing something like so:


$ screen
// Now we are in a new session
$ ngrok http 8080
// Now ngrok is running, exposing http port 8080
Type ctrl-a
// Now we are in screen’s command mode
Type the “d” key, to “detach”. 
// Now you are back in the shell that you started in, while screen is running your ngrok command in the background:
$ screen -list
There is a screen on:
        128861.pts-0.dev3       (04/25/24 14:36:58)     (Detached)

Since there’s only the one screen running, you can type $ screen -r (for re-attach) and you’ll be back in your ngrok session.

When you have multiple screens, you can rejoin them by typing $ screen -r <screen-id>. For example, $ screen -r 128861.

If you want to kill your session, you can join it, stop ngrok with Ctrl-c, and then type exit on the prompt to detach and kill the session.

Matthew Tyson

There’s a lot more you can do with screen. Check the docs here: https://www.gnu.org/software/screen/manual/screen.html.

Sdkman and nvm

If you are a programmer who uses Java or JavaScript on the server, you owe it to yourself to get familiar with sdkman (for Java) and nvm (for Node). Both tools are useful for juggling multiple versions of the language on the same machine and will let you eliminate adjusting the path and environment variables.

I use sdkman all the time to explore newer versions of Java and then jump back into the current LTS release. An sdk command makes the process painless. Here’s sdk showing me all the available Java installs on my local machine, including the one currently in use:

Matthew Tyson

Learn more about sdk: https://sdkman.io.

Switching between versions is simple: $ sdk use java 19-open lets me switch to open JDK version 19 in one fell swoop:


$ tldr sdk
Manage parallel versions of multiple Software Development Kits.
Supports Java, Groovy, Scala, Kotlin, Gradle, Maven, Vert.x and many others.

Node’s nvm utility works much the same:


$ tldr nvm
Install, uninstall or switch between Node.js versions.
Supports version numbers like "12.8" or "v16.13.1", and labels like "stable", "system", etc.
Matthew Tyson

Learn more about nvm: https://github.com/nvm-sh/nvm.

Fzf

Both grep and find are standard parts of the command-line palette. But after several decades using them, I still wrestle with looking for a file on disk if it is in any way complicated. Neither tool is as functional as it could be.

Enter fzf—a “fuzzy” file finder. By fuzzy we mean, it’s good at searching for what you need when you are a bit fuzzy on the details. Here’s an example:


$ tldr fzf
Command-line fuzzy finder.
Similar to sk.

You have to try fzf to fully appreciate it. When you launch the tool on your command line, it immediately goes to work indexing the file system. Then it begins offering you suggestions. Whatever you type, it comes back with a list of possible hits. Here’s me looking for a recent project I worked on:

Matthew Tyson

Learn more about fzf: https://github.com/junegunn/fzf.

Out of 878,937 possibilities, fzf picked out the 25 files and directories that might fit my needs. And it did so simply, with no finagling.

Exa

This utility takes your boring old ls listings and makes them more fun and useful:


$ tldr
A modern replacement for ls (List directory contents). 

For a better developer experience without any mental overhead, just alias ls to exa. Exa respects most standard ls options, so for example, exa -l works just like you’d expect.

Matthew Tyson

Learn more about exa: https://the.exa.website/#installation.

Bat

The bat util is like cat, only better:


$ tldr bat
Print and concatenate files.
A cat clone with syntax highlighting and Git integration.

This is another creature-comfort (or DX) improvement, similar to exa’s evolution of ls.

When you use bat, you get a full-blown file viewer with title, borders, line numbers and—most beneficial for coders—syntax highlighting for programming languages and config files. 

Bat responds to less/more commands, so “q” is used to exit. Navigating is as you would expect, using the arrow keys.

It’s a simple utility that really elevates the experience of browsing through files on the console.

Matthew Tyson

Learn more about bat: https://github.com/sharkdp/bat.

Nethack

We’ve looked at a bunch of awesome tools, some new and some old. One remaining classic every CLI aficionado should know about is nethack.

This is the original console-based ASCII dungeon crawler. It won’t help you be more productive directly, but it might help you stop for a few minutes and let your subconscious mind work on the problems you are facing.

Yes, there are newer takes on this model, but nethack remains the eternal classic:

Matthew Tyson

How to install nethack: https://packages.debian.org/sid/nethack-console.

Exit mobile version