exa vs ls
I’m not sure why, but recently I’ve seen several articles extolling the virtues exa over ls. Since it seems to be a thing right now, at least to me, I thought I’d give it a go.
For those that aren’t aware of what exa is, the man page describes it as “a modern replacement for ls”. That’s fairly succinct. The man page for ls says it’s an application to “list directory contents”. Also succinct.
So, how do they compare?
The first thing I had to do was install exa. ls was already there of course. I haven’t seen a Linux distribution ever that didn’t have ls installed. The installation was trivial in Fedora 33.
sudo dnf install exa
That was all it took to get it up and running.
This image is a side by side of exa and ls in the same directory. Both are long form with some of my favorite flags.
The first thing that jump out at me is the automatic color in exa. This is absolutely possible in ls but I’ve never bothered. Not that I don’t like it, I’m just too lazy to have actually configured it.
The second thing is the automatic human readable file sizes in exa. In ls this requires a -h flag. Again, that’s a trivial addition to your command line (and easy to default to if you’re so inclined), but it’s nice to have that your default option.
The third thing was the fact that the group wasn’t automatically listed in the exa output. I’m not sure if this is a good or bad thing, but I’m used to seeing it and I like having it there, so I added a -g to the -l I already had in my exa defaults, and all was good with the world.
After that, I dug into the man pages a little bit more, and found some other options with exa that I really liked. I added headers to the output with a -h flag. This threw me off a little bit because that’s the human readable flag in ls. I realize they’re two different apps, but because exa is a modern replacement for ls, I expected them to more closely emulate the flags from ls. Not that they need to, but I thought they would.
I also added the –group-directories-first flag. This option is available in both exa and ls, and does exactly the same thing. Some people like it, some don’t. I find it handy to have all my directories grouped at the top of the output. Your mileage may vary.
The last thing I did was add the –git flag. This is a really cool little option that will display the git status of files. So, as I’m writing this post I’ve already checked in the file, but the version on my computer is modified from the version in the git repo. Because of that I see a little -M in the exa output. This may not be useful to everybody, but I think that is a really cool option to have.
So, will I be using exa instead of ls in the future? Probably. There’s two reasons I might not.
One, it’s not installed on every system by default. Quite often I work on Linux systems I don’t have full admin access on, and can’t install things at whim. The odds that those systems will have exa is pretty low, so I’m going to continue to use ls in those cases.
Two, muscle memory. I’ve been typing ls at my command line for close to thirty years now. I don’t even think about it. When I’m thinking about something and a terminal window is on the screen, sometimes I just type “clear;ls” over and over again without thinking about it. “exa” just doesn’t roll off my fingertips with quite the same ease. In fact, to make sure I’m using exa instead of ls on my personal Linux machines, I’ve done this:
alias ls="exa -lhg --git --group-directories-first"
I’m still typing ls, but I’m getting all the benefits of exa without having to retrain myself while fighting against the systems I can’t install exa on.
If you’re looking to improve your directory listing output, I’d definitely suggest giving exa a try. If you don’t like it, it’s no big deal to go back to ls
Day 17 of the #100DaysToOffload 2021 Series.
Looking for comments? There are no comments. It's not that I don't care what you think, it's just that I don't want to manage a comments section.
If you want to comment, there's a really good chance I at least mentioned this post on Fosstodon, and you can reply to me there. If you don't have a Mastodon account, I'd suggest giving it a try.
If you don't want to join Mastodon, and you still want to comment, feel free to use my contact information.