Handle invalid UTF-8 characters in filenames
mainlsd attempts to display UTF-8 characters in filenames. If a filename contains invalid UTF-8, lsd will display the U+FFFD REPLACEMENT CHARACTER (�) to represent the invalid data.repository·main·Indexed 12 days ago
https://github.com/lsd-rs/lsdA modern rewrite of the GNU ls command written in Rust, featuring colors, icons, tree-view, and advanced formatting options. Version 1.2.0 supports custom configuration via YAML files, Nerd Font integration for icons, and extensive CLI flags for sorting and display.
lsd attempts to display UTF-8 characters in filenames. If a filename contains invalid UTF-8, lsd will display the U+FFFD REPLACEMENT CHARACTER (�) to represent the invalid data.LSD can be installed via various package managers, from source using Cargo, or by downloading precompiled binaries.
### Installing from source
With Rust's package manager cargo, you can install lsd via:
```sh
cargo install lsdTo enable Nerd Fonts for the URxvt terminal emulator, add the following line to your .Xresources file, replacing Hack Nerd Font with your specific installed Nerd Font name.
URxvt*font: xft:Hack Nerd Font:style=Regular:size=11Use the command corresponding to your operating system or distribution:
| OS/Distro | Command |
|---|---|
| Archlinux | pacman -S lsd |
| Fedora | dnf install lsd |
| Gentoo | sudo emerge sys-apps/lsd |
| macOS | brew install lsd or sudo port install lsd |
| Nix (non NixOS) | nix-env -iA nixpkgs.lsd |
| NixOS | Add environment.systemPackages = [ pkgs.lsd ]; to system config |
| FreeBSD | pkg install lsd |
| NetBSD/pkgsrc | pkgin install lsd or cd /usr/pkgsrc/sysutils/lsd && make install |
| OpenBSD | pkg_add lsd |
| Windows | scoop install lsd or winget install --id lsd-rs.lsd or choco install lsd |
| Android (Termux) | pkg install lsd |
| Debian (sid/bookworm) | apt install lsd |
| Ubuntu 23.04+ | apt install lsd |
| Solus | eopkg it lsd |
| Void Linux | sudo xbps-install lsd |
| openSUSE | sudo zypper install lsd |
lsd by using the LS_COLORS environment variable. For help with creating complex themes, you can refer to external resources like trapd00r/LS_COLORS or sharkdp/vivid. Other colors (such as permissions, dates, and sizes) are managed via the lsd theme configuration.The lsd command provides an enhanced directory listing experience with colors and icons. You can list the current directory, a specific path, or use flags to modify the output format.
lsdlsd /path/to/dirlsd -a or lsd --alllsd -l or lsd --longlsd -lalsd -laYou can customize icons using Nerd Font glyphs or Unicode emojis. lsd supports three types of icon overrides in icons.yaml:
name: Matches specific file or directory names (e.g., .cargo).extension: Matches file extensions (e.g., rs).filetype: Matches general categories (e.g., dir, executable, symlink-file).Custom icons are merged with the default set provided in the source.
name:
.trash:
.cargo:
.emacs.d:
a.out:
extension:
go:
hs:
rs: 🦀
filetype:
dir: 📂
file: 📄
pipe: 📩
socket:
executable:
symlink-dir:
symlink-file:
device-char:
device-block:
special: To use lsd instead of the standard ls command, add an alias to your shell configuration file (e.g., ~/.bashrc, ~/.zshrc).
Basic replacement:
alias ls='lsd'Useful productivity aliases:
alias l='lsd -l'
alias la='lsd -a'
alias lla='lsd -la'
alias lt='lsd --tree'alias ls='lsd'
alias l='lsd -l'
alias la='lsd -a'
alias lla='lsd -la'
alias lt='lsd --tree'lsd relies on the LS_COLORS system environment variable. If your custom colors are not appearing, ensure that LS_COLORS is correctly set in your environment.LSD's color settings are determined by two main components: when (how to use colors) and theme (which color scheme to use). These settings can be configured via CLI flags, the configuration file, or environment variables.
ColorOption)Controls when colors are displayed in the output:
always: Always use color.auto: Use color automatically (default behavior).never: Never use color.Note: Enabling --classic mode (via CLI or config) forces the color option to never.
ThemeOption)Controls the color scheme applied:
default: Use the built-in default theme.custom: Use a custom YAML theme file.no-color: Disable colors entirely.<path>: Provide a path to a custom legacy theme file.Note: If classic mode is enabled in the configuration, the theme is automatically set to NoColor.
You can prevent lsd from displaying certain files or directories by using glob patterns. These patterns can be specified via the CLI or in your configuration file.
If patterns are defined in multiple places, lsd follows this order of precedence:
--ignore-glob)ignore-globs)--ignore-glob flag.ignore-globs key.# CLI Example
lsd --ignore-glob ".git" --ignore-glob "node_modules"
# Configuration Example (YAML/JSON style)
ignore-globs: [ ".git", "node_modules" ]The permission display format is determined by a hierarchy of settings:
--classic is passed, the format is set to rwx. Otherwise, the value provided to --permission takes precedence.classic = true, the format is set to rwx. Otherwise, the value of the permission key is used.rwx is the default.attributes is the default.