Using exa as a modern replacement to the venerable Unix ls command

Julien Ponge
3 min readNov 21, 2020

--

So you know ls (often found as /bin/ls), the good old Unix command to list files in a directory.

I recently came across exa, a modern replacement for ls. It is part of a wave of new command-line tools written in Rust and that bring modernity while staying faithful to the Unix way of writing focused and composable tools.

Of course you may wonder why switching from ls is any good idea. It turns out that exa is really a better ls, with good colour support, customisable output, a humane interface and even git metadata support (so you can see which files are being ignored, staged, etc).

A quick tour of exa

The default behavior of exa is to... list files, pretty much like ls would do:

The equivalent of ls -la is exa --long --all:

Note that by default file sizes are given in a human-friendly form.

If you are in a Git repository you can also get metadata by adding the --git flag to any command:

Note that reading Git metadata can slow down the execution of exa commands, so I personally tend to use the --git flag only when I actually need it.

You can also inspect trees with the --tree flag:

There is also a --recurse flag to list files in each directory of the file tree:

My personal aliases

Typing exa instead of ls is one more character, and you'll likely have to fight muscle memory. In my case I am trying to get rid of typing ls -lsa 😉

You can easily define a few aliases so exa becomes your new ls. Note that exa is not fully compatible with ls. For instance ls -lsa (which I am fighting) results in an error with exa -lsa because the -s flag requires an argument to define a sort field.

Here are my personal aliases:

Feel-free to take inspiration and define aliases and default flags that make sense to you!

Originally published at https://julien.ponge.org on November 21, 2020.

--

--

Julien Ponge
Julien Ponge

Written by Julien Ponge

Computer scientist. Hackademic. Does more with less.

No responses yet