eza
一个现代化的,ls
的平替命令。
eza
是Unix
和Linux
操作系统附带的古老的文件列表命令行程序ls
的现代、可维护的替代品,它提供了更多的功能和更好的默认值。它使用颜色来区分文件类型和元数据。它知道符号链接、扩展属性和Git
。它体积小,速度快。
官网:eza | A modern, maintained replacement for ls
安装
基于Ubuntu
系统
$ apt update
$ apt install -y gpg
$ mkdir -p /etc/apt/keyrings
$ wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
$ echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
$ chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
$ apt update
$ apt install -y eza
语法
eza [选项] [文件名...]
选项
-1, --oneline: 每行显示一个条目
-l, --long: 将条目显示为单行(默认)
-R, --recurse: 递归显示
-T, --tree: 以树形递归显示
-G, --grid: 将条目按顺序(向下)显示(默认)
-x, --across: 对目标进行横向排序,而不是向下排序
-F, --classify: 按文件名显示类型指示符
--colo[u]r: when to use terminal colours
--colo[u]r-scale: highlight levels of file sizes distinctly
--icons: 显示图标
--no-icons: 不显示图标(总是覆盖图标)
--hyperlink: 将目标显示为超链接
-w, --width=(columns): 按列设置屏幕宽度
过滤选项
时间紧张,暂时没有翻译。
-a, --all: show hidden and 'dot' files
-d, --list-dirs: list directories like regular files
-L, --level=(depth): limit the depth of recursion
-r, --reverse: reverse the sort order
-s, --sort=(field): which field to sort by
--group-directories-first: list directories before other files
-D, --only-dirs: list only directories
-f, --only-files: list only files
--git-ignore: ignore files mentioned in .gitignore
-I, --ignore-glob=(globs): glob patterns (pipe-separated) of files to ignore
长选项
当使用 --long
或者 -l
的时候起作用
-b, --binary: list file sizes with binary prefixes
-B, --bytes: list file sizes in bytes, without any prefixes
-g, --group: list each file’s group
-h, --header: add a header row to each column
-H, --links: list each file’s number of hard links
-i, --inode: list each file’s inode number
-m, --modified: use the modified timestamp field
-M, --mounts: Show mount details (Linux and MacOS only).
-S, --blocksize: show size of allocated file system blocks
-t, --time=(field): which timestamp field to use
eza: Flag -t needs a value (choices: modified, changed, accessed, created)
-u, --accessed: use the accessed timestamp field
-U, --created: use the created timestamp field
-X, --dereference: dereference symlinks for file information
-Z, --context: list each file’s security context
-@, --extended: list each file’s extended attributes and sizes
--changed: use the changed timestamp field
--git: list each file’s Git status, if tracked or ignored
--git-repos: list each directory’s Git status, if tracked
--git-repos-no-status: list whether a directory is a Git repository, but not its status (faster)
--no-git: suppress Git status (always overrides --git, --git-repos, --git-repos-no-status)
--time-style: how to format timestamps. valid timestamp styles are ‘default’, ‘iso’, ‘long-iso’, ‘full-iso’, ‘relative', or you can use a custom style with '+' as prefix. (Ex: "+%Y/%m/%d, %H:%M" => "2023/9/30, 12:00"). more about format syntax.
--no-permissions: suppress the permissions field
-o, --octal-permissions: list each file's permission in octal format
--no-filesize: suppress the filesize field
--no-user: suppress the user field
--no-time: suppress the time field
范例
$ eza # 仅列出当前目录可见文件
$ eza -a # 显示当前目录下包括隐藏文件在内的所有文件列表
$ ls -l # 列出当前目录可见文件详细信息
$ ls -hl # 列出详细信息并以可读大小显示文件大小
$ eza -al # 列出所有文件(包括隐藏)的详细信息
$ du -sh * | sort -h # 按文件大小排序(同上)
输出长格式列表
$ eza -l
.rw-r--r-- 18 root 11 Oct 22:38 99.sh
drwxr-xr-x - root 11 Oct 22:13 eza
.rw-r--r-- 0 root 11 Oct 22:38 file1
水平输出文件列表
$ eza -x
99.sh eza file1
显示文件的inode信息
$ eza -li 99.sh file1
787074 .rw-r--r-- 18 root 11 Oct 22:38 99.sh
787072 .rw-r--r-- 0 root 11 Oct 22:38 file1
修改最后一次编辑的文件 最近修改的文件显示在最上面。
$ eza -lt changed
.rw-r--r-- 18 root 11 Oct 22:38 99.sh
drwxr-xr-x - root 11 Oct 22:13 eza
.rw-r--r-- 0 root 11 Oct 22:38 file1
递归显示文件
$ eza -R
99.sh eza file1
./eza:
benches Cargo.lock CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md deny.toml flake.lock Justfile man rust-toolchain.toml screenshots.png snap tests
build.rs Cargo.toml cliff.toml completions deb.asc devtools flake.nix LICENCE README.md rustfmt.toml SECURITY.md src treefmt.nix
组合查询,显示git信息。
$ eza -l --git --git-repos --header
Permissions Size User Date Modified Git Repo Name
drwxr-xr-x - root 11 Oct 22:13 -- - - benches
.rw-r--r-- 3.9k root 11 Oct 22:13 -- - - build.rs
.rw-r--r-- 37k root 11 Oct 22:13 -- - - Cargo.lock
.rw-r--r-- 2.9k root 11 Oct 22:13 -- - - Cargo.toml
.rw-r--r-- 24k root 11 Oct 22:13 -- - - CHANGELOG.md
.rw-r--r-- 2.5k root 11 Oct 22:13 -- - - cliff.toml
.rw-r--r-- 5.5k root 11 Oct 22:13 -- - - CODE_OF_CONDUCT.md
drwxr-xr-x - root 11 Oct 22:13 -- - - completions
.rw-r--r-- 3.5k root 11 Oct 22:13 -- - - CONTRIBUTING.md
.rw-r--r-- 1.7k root 11 Oct 22:13 -- - - deb.asc
.rw-r--r-- 12k root 11 Oct 22:13 -- - - deny.toml
drwxr-xr-x - root 11 Oct 22:13 -- - - devtools
.rw-r--r-- 5.3k root 11 Oct 22:13 -- - - flake.lock
.rw-r--r-- 6.5k root 11 Oct 22:13 -- - - flake.nix
.rw-r--r-- 7.4k root 11 Oct 22:13 -- - - Justfile
.rw-r--r-- 1.1k root 11 Oct 22:13 -- - - LICENCE
drwxr-xr-x - root 11 Oct 22:13 -- - - man
.rw-r--r-- 16k root 11 Oct 22:13 -- - - README.md
.rw-r--r-- 146 root 11 Oct 22:13 -- - - rust-toolchain.toml
.rw-r--r-- 34 root 11 Oct 22:13 -- - - rustfmt.toml
.rw-r--r-- 1.1M root 11 Oct 22:13 -- - - screenshots.png
.rw-r--r-- 505 root 11 Oct 22:13 -- - - SECURITY.md
drwxr-xr-x - root 11 Oct 22:13 -- - - snap
drwxr-xr-x - root 11 Oct 22:13 -- - - src
drwxr-xr-x - root 11 Oct 22:13 -- - - tests
.rw-r--r-- 434 root 11 Oct 22:13 -- - - treefmt.nix