lsd README

The project's README from github.com/lsd-rs/lsd. As one markdown file: README.md.

Special thanks to:
Maintained with ❤️ + 🤖 by Pochi

Pochi AI Coding Assistant

Pochi is an AI agent designed for software development.

It operates within your IDE, using a toolkit of commands to write and refactor code autonomously across your entire project.


[!IMPORTANT] This is the documentation for the development version of lsd. Please consult the documentation on the Tags page if you are looking for the documentation of individual releases.

The current newest release is: v1.2.0

LSD (LSDeluxe)

license Latest version build codecov versions

lsd sample output

This project is a rewrite of GNU ls with lots of added features like colors, icons, tree-view, more formatting options etc. The project is heavily inspired by the super colorls project.

Installation

Prerequisites

[!TIP] Have a look at the Nerd Font README for help with installing Nerd Fonts

  1. In order for icons to work you need to have a patched font like nerd-font or font-awesome installed on your machine and your terminal needs to be configured to use the patched font of your choosing.
  2. If you intend to install lsd from source you need to have a working Rust toolchain (obviously) on your machine.

Installing with a package manager

Packaging status Packaging status

Please consult the table below for the installation command associated with your package manager.

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 your system config
FreeBSD pkg install lsd
NetBSD or any pkgsrc platform 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 (via Termux) pkg install lsd
Debian sid and bookworm apt install lsd
Ubuntu 23.04 (Lunar Lobster) apt install lsd
Earlier Ubuntu/Debian versions snap discontinued, use the method described here instead
Solus eopkg it lsd
Void Linux sudo xbps-install lsd
openSUSE sudo zypper install lsd

Installing from source

With Rust's package manager cargo, you can install lsd via:

cargo install lsd

And if you want to install the latest main branch commit you can do so via:

cargo install --git https://github.com/lsd-rs/lsd.git --branch main

Installing binaries directly

The release page includes precompiled binaries for Linux, macOS, and Windows for every release. You can also get the latest binary of the main branch from the GitHub action build artifacts (choose the top action and then scroll down to the artifacts section).

Configuring your shell to use lsd instead of ls (optional)

In order to use lsd instead of entering the ls command, you need to create an alias for ls in to your shell configuration file (~/.bashrc, ~/.zshrc, etc...). The simplest variant of such an alias is:

alias ls='lsd'

The alias above will replace a stock ls command with an lsd command without additional parameters.

Some examples of other useful aliases are:

alias l='lsd -l'
alias la='lsd -a'
alias lla='lsd -la'
alias lt='lsd --tree'

Customizing lsd (configuration and theming)

[!TIP] In order to make the customization process easier for you we’ve supplied sample files. These files contain the entries for all the defaults that lsd comes with after installation. You can find the sample files in the documentation folder.

We've also supplied a color reference where we’ve documented the default colors lsd uses in its output. You can also preview there.

In order to tailor lsd to your specific needs you can create any of the following three files and make adjustments as you see fit.

  1. config.yaml → config sample file here
  2. colors.yaml → colors sample file here
  3. icons.yaml → icons sample file here

Note that it is not required to have all three of the files present in order for your configuration to be applied. For example, if you only want to customize the icons then only icons.yaml needs to be present in the configuration directory; config.yaml, and colors.yaml do not have to be present in order for your icon modifications to be applied.

Config file locations

[!TIP] You can also instruct lsd to look for configuration files in a custom location of your choosing by using the following command: lsd --config-file [YOUR_CUSTOM_PATH]. This is particularly useful when testing a configuration changes before committing to them.

Unix (Linux, Mac, etc...)

On non-Windows systems lsd follows the XDG Base Directory Specification, thus lsd will look for configuration files any of the following locations:

On most systems these variables are mapped to the same location, which is usually ~/.config/lsd/. If lsd does not detect the location, or if the location exists but does not contain any of the three configuration files, the default configuration will be used instead.

Windows

On Windows systems lsd will look for configuration files in the following locations, in order:

  1. %USERPROFILE%\.config\lsd
  2. %APPDATA%\lsd

These locations are usually something like C:\Users\username\AppData\Roaming\lsd\, and C:\Users\username\.config\lsd\ respectively.

Quick customization example

For this example let's assume you're already content lsd, but there are a few of the default icons that really bug you and you want to change them to something that suits your needs better. All you have to do is create an icons.yaml file in the configuration directory and configure your custom icon there. Here’s how.

There are 3 kinds of icon overrides available in lsd:

Both nerd font glyphs and Unicode emojis can be used for icons. The final set of icons that lsd will use is a combination of the default icons with the custom icons you’ve set in the icons.yaml file.

[!NOTE] Aside from the icon sample file, you can also find the default icon set in the source code here.

A short example for each type of the icon overrides is shown below.

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: 

F.A.Q and troubleshooting

How can I enable nerd fonts using xresources?

To enable nerd fonts for your terminal, URxvt for example, in .Xresources take a look at the example below:

URxvt*font:    xft:Hack Nerd Font:style=Regular:size=11

Why am I seeing Uses unknown compression for member ‘control.tar.zst' when using deb?

Zst compression is only supported from Debian 12, Ubuntu 21.10, and upward. Starting from lsd v1.1.0 please use the _xz.deb release instead. See this issue for additional details and manual fixes.

How can I set custom color schemes for Windows?

In order to display a custom color scheme lsd reads a system environment variable called LS_COLORS. If your custom color scheme is not working LS_COLORS is most likely missing. Please look at the marked solution in this post, which contains instructions on how to set a custom color scheme on Windows for guidance.

Why are icons not showing up

[!IMPORTANT] Always check if the font you are using is correctly set up! Run the following snippet in your terminal emulator and verify that the output prints a folder icon. If it prints a box, or question mark, or something else, then you might have some issues in how you set up the font or how your terminal emulator renders the font.

echo $'\uf115'

For lsd to be able to display icons the font has to include special font glyphs. If icons are not being displayed it could be the case that your current font does not include such glyphs. Thankfully, you can patch most fonts using NerdFont and add these icons to your current font.

Alternatively, you can also download an already patched version of your favorite font from the NerdFont font download page.

Here is a guide on how to set up fonts on macOS, and on Android.

Why are Icons missing or not rendering correctly using PuTTY/KiTTY on Windows?

First of all, make sure a patched font is available on your local machine and that PuTTY/KiTTY is configured to use that font. If you are not certain what this entails please read the Prerequisites.

Please note that there are problems for PuTTY/KiTTY displaying 2 character wide icons which may be the case for the font you configured. To ensure only 1 character wide icons are used by your font, please select a font like Hack Regular Nerd Font Complete Mono Windows Compatible (see this issue for further details).

Why is the first character of a folder/file getting trimmed?

[!NOTE] Workaround for Konsole: edit the config file (or create it if it doesn't already exist) and paste the following configuration directive into it.

# CAREFUL: use copy-paste because this block contains invisible Unicode characters!
  icons:
    separator: " ㅤ"

This is a known issue in a few terminal emulators. Try using a different terminal emulator like Alacritty or Kitty and see if these suit your needs.

You might also want to check if your font is responsible for causing this. To verify this, try running lsd with icons disabled and if the first character is still being trimmed, you’ve discovered a bug in lsd. Until the bug is fixed you can use the following command as workaround:

lsd --icon never --ignore-config

Why are there weird (UTF-8) characters in the output?

lsd will always attempt to display the UTF-8 characters in file name, but a U+FFFD REPLACEMENT CHARACTER(�) is used to represent the invalid UTF-8 characters. If you are seeing this in your lsd output your filename contains an invalid UTF-8 character.

Why are the icons are showing up strangely?

Nerd Fonts is moving the code points of the Material Design Icons in version 3.0, so starting from #830 lsd is using an updated the icon set. If your icons look weird, use fonts that have been patched using Nerd Fonts v2.3.0 or later.

Contributors

Everyone can contribute to this project, improving the code or adding functions. If anyone wants something to be added we will try to do it.

As this is being updated regularly, don't forget to rebase your fork before creating a pull-request.

Credits

Special thanks to:

lsd (lsd-rs/lsd)

Searching Database…

16.3K ·GitHub
这是什么东西?它是 LSD(LSDeluxe),用 Rust 重写的 GNU ls 命令,能在目录列表中加入颜色、图标、树状视图等更多格式化选项。它的设计深受 colorls 项目的启发。
它和普通的 ls 命令有什么区别?它是一个终端命令行工具,不是库也不是图形界面——你在 shell 里像 ls 一样运行它,或者设置一个别名,这样输入 ls 时实际运行的就是 lsd。
想让图标正常显示需要什么特殊条件吗?需要——必须安装经过修补的字体(比如 Nerd Font 或 Font Awesome),并把它配置为终端使用的字体。只有当你从源码构建 lsd 时才需要 Rust 工具链。
为什么我已经用了修补字体,图标看起来还是乱码?图标是最大的痛点:如果显示的是方框而不是图标,说明终端字体没有经过修补;用低于 v2.3.0 的 Nerd Fonts 修补的字体渲染图标也会不正常。PuTTY/KiTTY 还可能弄乱占两个字符宽度的图标。
除了 Linux,macOS 或 Windows 上也能用吗?可以——Linux、macOS、Windows 以及各 BSD 系统(FreeBSD、OpenBSD、NetBSD)都支持,大多数发行版和包管理器都有对应的安装命令。在 Android 上可以通过 Termux 运行。
我能让 lsd 默认替代 ls 吗?可以——在你的 shell 配置(~/.bashrc、~/.zshrc 等)里加一个别名,比如 alias ls='lsd',之后每次调用 ls 都会运行 lsd。README 里还展示了其他实用的别名示例,比如加上你一直想用的参数。
我能自定义它的外观吗?可以——通过 ~/.config/lsd 下最多三个 YAML 文件:config.yaml、colors.yaml 和 icons.yaml。只需要配置你想修改的那部分对应的文件即可;lsd --config-file [YOURCUSTOMPATH] 还能让你测试放在自定义位置的配置文件。在 Windows 上,配置文件夹会在你的用户目录和 AppData/Roaming 下查找。
我可以自定义哪些图标覆盖规则?有三种:按名称、按文件类型和按文件扩展名。既可以用 Nerd Font 字形,也可以用 Unicode 表情符号,而且你的自定义图标会和默认图标集合并。
What are similar projects?eza, oh-my-posh, exa, hyperfine, hexyl, fastfetch, fd, zoxide
Creator
lsd-rs
Size
1.7 MB
Stars
16.3K
Age
7y
Commits · 90 Days