A robust one-liner and shell function to use lsd (LSDeluxe) with all its NerdFont-powered visual glory β while hiding symlink targets (β path).
It preserves icons, formatting, and works beautifully in scripts and aliases.
Perfect for minimalist terminal users who love beauty without unnecessary clutter.
| Step | Purpose |
|---|---|
script -q -c "lsd -l" |
Runs lsd in a pseudo-terminal (PTY) to preserve icons and formatting that would otherwise be lost in a pipe. |
perl -pe 's/\r/\n/g; s/ β .*//' |
Converts terminal line-overwrites into proper newlines, and strips symlink targets while preserving icons. |
awk '!seen[$0]++' |
Removes duplicate lines caused by the overwrite behavior of PTYs. |
script -q -c "lsd -l --color=always" /dev/null \
| perl -pe 's/\r/\n/g; s/ β .*//' \
| awk '!seen[$0]++'Add this to your ~/.bashrc, ~/.zshrc, or equivalent shell config:
dls() {
script -q -c "lsd -l --color=always" /dev/null \
| perl -pe 's/\r/\n/g; s/ β .*//' \
| awk '!seen[$0]++'
}Then just run:
dlsEnjoy a clean, symlink-target-free, icon-rich ls output.
lsdinstalled (dnf install lsdor via your package manager)perlawkscript(fromutil-linux, usually installed by default)- NerdFont-compatible terminal (for full icon goodness)
Discovered and refined by Michael Longval and ChatGPT (aka Peregrin).
It took ANSI necromancy, regex diplomacy, and a brave stand against the tyranny of \r.