Skip to main content
Account
Guide

Tip 5: Replacing ls with exa

David Flanagan Jan 07, 2020 1 min read

Rust … slowly but surely, all applications are being rewritten in Rust.

My next few tips will cover a few of these :)

Exa

Exa is an ls replacement written in Rust. As they say in their README:

with more features and better defaults

What does it look like?

Output from Exa

Alt Text

Pretty shiny, eh?

Things worth noting:

  1. Colours that distinguish directories, files, and executable files
  2. Colours for permissions, owners, and size of file
  3. Git status of each file in long output

Trees Everywhere

When working with code, it can be pretty nice to get a tree style look at the repository. Exa surpasses expectations here too.

First, here are a few aliases I have configured:

Terminal window
# ls
TREE_IGNORE="cache|log|logs|node_modules|vendor"
alias ls=' exa --group-directories-first'
alias la=' ls -a'
alias ll=' ls --git -l'
alias lt=' ls --tree -D -L 2 -I ${TREE_IGNORE}'
alias ltt=' ls --tree -D -L 3 -I ${TREE_IGNORE}'
alias lttt=' ls --tree -D -L 4 -I ${TREE_IGNORE}'
alias ltttt=' ls --tree -D -L 5 -I ${TREE_IGNORE}'

Let me explain:

  • --tree - Enables Tree display
  • -D - Show directories only (Useful for large trees)
  • -L n - How many levels deep to display
  • -I ${TREE_IGNORE} - This omits/hides common vendor directories, as defined in the variable above the aliases

Here’s a short asciinema of me using the lt, ltt, and lttt aliases:

View terminal recording

Published Jan 07, 2020

Related Articles

Related Videos

Rawkode Academy newsletter

Academy publications by email

Get an email when Rawkode Academy publishes new tutorials, articles, and videos.

Loading email signup. If it does not load, manage email preferences in account settings.