eza: How to Alias "ls"

Updated

Learn how to replace "ls" with eza in Zsh or Bash using pipe-safe icons and shortcuts

eza: How to Alias ls to eza

Before we start, make sure you have eza installed on your computer. If you don't have it yet, install it with Homebrew:

brew install eza

Add the Alias to Your Shell Config

Open your shell configuration file—~/.zshrc on macOS with Zsh, or ~/.bashrc on Linux with Bash—and add your default ls replacement along with a few optional shortcuts:

# Default replacement (pipe-safe icons and directories listed first)
alias ls='eza --icons=auto --group-directories-first'
# Optional helpful shortcuts
alias ll='eza -lh --icons=auto --git --group-directories-first'
alias la='eza -lah --icons=auto --git --group-directories-first'
alias lt='eza --tree --level=2 --icons=auto'

Using --icons=auto instead of --icons prevents icon characters from breaking output when you pipe ls into other commands like grep or fzf, while --group-directories-first keeps folders neatly at the top.

Reload Your Configuration

Apply the changes right away so the new aliases take effect immediately:

source ~/.zshrc

If you're using Bash, run source ~/.bashrc instead. Then run ls or ll to confirm everything looks right.

undefined

If you ever need the original macOS ls command for a one-off call without removing your alias, just prefix it with a backslash like \ls.