DEV Community

Joel Jucá
Joel Jucá

Posted on

Pst! Hey, come here. I have LSD 😎

No, you didn't read it wrong. I'm here to tell you about LSD - how cool it is, how to use it, and how to incorporate some awesomeness in your life. Once you taste it, you'll never be the same anymore!


LSD is a Rust-powered ls-like command to list directories and files in your terminal. It works pretty much like ls and can be used as a drop-in replacement, as most of the commonly used options are supported.

The cool thing about LSD is that it improves the file/directory listing experience by cleverly coloring its output, showing some icons beside names, and also providing some interesting customization parameters.

You can just use lsd where you would normally use ls. You could also alias ls to lsd and continue to use it as you normally would:

alias ls="lsd"
Enter fullscreen mode Exit fullscreen mode

Note: ls contains far more options than LSD, and probably should be used when writing shell scripts. Otherwise, for daily work/routine commands, LSD should be safe enough.

My experience with LSD

I've been using LSD for some days now and the experience is good. I feel the file icons and the relative dates help me a lot to find the exact file I'm looking for when I ls somewhere.

Here's my ~/.zshrc alias:

alias ls="lsd --date=relative --group-dirs=first --size=short"
Enter fullscreen mode Exit fullscreen mode

I also wrapped this alias into a which expression that checks if I have the lsd binary available in my $PATH, to avoid errors when using my .zshrc in environments where LSD is not installed/available. So my alias became like this:

which lsd > /dev/null 2>&1 && alias ls="lsd --date=relative --group-dirs=first --size=short"
Enter fullscreen mode Exit fullscreen mode

Using LSD

Using LSD is literally the same as using ls. I'll avoid placing installation instructions here as it might become outdated.

The LSD home page is

As of today, the latest LSD version is 0.19.0. You can check all its optional parameters through --help:

$ lsd --help
lsd 0.19.0
An ls command with a lot of pretty colors and some other stuff.

    lsd [FLAGS] [OPTIONS] [--] [FILE]...

    -a, --all               Do not ignore entries starting with .
    -A, --almost-all        Do not list implied . and ..
        --classic           Enable classic mode (no colors or icons)
    -L, --dereference       When showing file information for a symbolic link, show information for the file the link references rather than for the link itself
    -d, --directory-only    Display directories themselves, and not their contents (recursively when used with --tree)
    -X, --extensionsort     Sort by file extension
        --help              Prints help information
    -h, --human-readable    For ls compatibility purposes ONLY, currently set by default
        --ignore-config     Ignore the configuration file
    -F, --classify          Append indicator (one of */=>@|) at the end of the file names
    -i, --inode             Display the index number of each file
    -l, --long              Display extended file metadata as a table
        --no-symlink        Do not display symlink target
    -1, --oneline           Display one entry per line
    -R, --recursive         Recurse into directories
    -r, --reverse           Reverse the order of the sort
    -S, --sizesort          Sort by size
    -t, --timesort          Sort by time modified
        --total-size        Display the total size of directories
        --tree              Recurse into directories and present the result as a tree
    -V, --version           Prints version information
    -v, --versionsort       Natural sort of (version) numbers within text

        --blocks <blocks>...            Specify the blocks that will be displayed and in what order [possible values: permission, user, group, size, date, name, inode]
        --color <color>...              When to use terminal colours [default: auto]  [possible values: always, auto, never]
        --date <date>...                How to display date [possible values: date, relative, +date-time-format] [default: date]
        --depth <num>...                Stop recursing into directories after reaching specified depth
        --group-dirs <group-dirs>...    Sort the directories then the files [default: none]  [possible values: none, first, last]
        --icon <icon>...                When to print the icons [default: auto]  [possible values: always, auto, never]
        --icon-theme <icon-theme>...    Whether to use fancy or unicode icons [default: fancy]  [possible values: fancy, unicode]
    -I, --ignore-glob <pattern>...      Do not display files/directories with names matching the glob pattern(s). More than one can be specified by repeating the argument [default: ]
        --size <size>...                How to display size [default: default]  [possible values: default, short, bytes]
        --sort <WORD>...                sort by WORD instead of name [possible values: size, time, version, extension]

    <FILE>...     [default: .]
Enter fullscreen mode Exit fullscreen mode

If you use LSD and enjoy it, let me know how awesome it is for you in the comments below. 😉

Top comments (0)