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.
๐ง What It Does
| 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. |
โ One-Liner
script -q -c "lsd -l --color=always" /dev/null \ | perl -pe 's/\r/\n/g; s/ โ .*//' \ | awk '!seen[$0]++'
๐งฐ Shell Function
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:
Enjoy a clean, symlink-target-free, icon-rich ls output.
๐ฅ๏ธ Requirements
lsdinstalled (dnf install lsdor via your package manager)perlawkscript(fromutil-linux, usually installed by default)- NerdFont-compatible terminal (for full icon goodness)
โจ Credit
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.