Exa替代ls命令的超好用工具

2023-10-20 09:36:47 浏览数 (2)

简述

exa is an improved file lister with more features and better defaults. It uses colours to distinguish file types and metadata. It knows about symlinks, extended attributes, and Git. And it’s small, fast, and just one single binary.

Exa是一个漂亮的命令行工具,它能够使用不同的颜色来显示各种文件类型、文件权限和所有权、block和inode的信息等。

官网:https://the.exa.website/ GITHUB:https://github.com/ogham/exa

安装

一般来说,安装有两种方法:通过软件包管理安装和源码来安装。

软件包管理安装

代码语言:javascript复制
On Arch, install the exa package with pacman -S exa.
On Debian, install the exa package. with apt install exa.
On Fedora, install the rust-exa package with sudo dnf install exa.
On Gentoo, install the rust-exa package with emerge sys-apps/exa.
On NixOS, install the exa package with nix-env -i exa.
On openSUSE, install the exa package with sudo zypper install exa.
On Ubuntu, On Ubuntu 20.10 (Groovy Gorilla) and later, install the exa package with apt install exa.

源码包安装

源码包编译安装
代码语言:javascript复制
➜  build yum install libgit2 cmake
➜  build curl https://sh.rustup.rs -sSf | sh
➜  build git clone https://github.com/ogham/exa/archive/v0.9.0.tar.gz
➜  exa cd exa
➜  examake install
二进制文件安装

1.安装rust语言支持

代码语言:javascript复制
➜  ~ curl https://sh.rustup.rs -sSf | sh
info: downloading installer
Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /root/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /root/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /root/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /root/.profile
  /root/.zprofile
  /root/.bash_profile

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2020-10-08, rust version 1.47.0 (18bf6b4f0 2020-10-07)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
 21.2 MiB /  21.2 MiB (100 %)  12.9 MiB/s in  1s ETA:  0s
info: downloading component 'rustc'
 66.5 MiB /  66.5 MiB (100 %)  12.5 MiB/s in  5s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: Defaulting to 500.0 MiB unpack ram
info: installing component 'clippy'
info: installing component 'rust-docs'
 12.9 MiB /  12.9 MiB (100 %)   4.0 MiB/s in  3s ETA:  0s
info: installing component 'rust-std'
 21.2 MiB /  21.2 MiB (100 %)   8.2 MiB/s in  2s ETA:  0s
info: installing component 'rustc'
 66.5 MiB /  66.5 MiB (100 %)   6.8 MiB/s in 12s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable'

  stable installed - rustc 1.47.0 (18bf6b4f0 2020-10-07)


Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run source $HOME/.cargo/env

2.下载二进制文件的压缩包

代码语言:javascript复制
➜  ~ wget --no-check-certificate https://github.com/ogham/exa/releases/download/v0.9.0/exa-linux-x86_64-0.9.0.zip
--2020-10-13 12:11:01--  https://github.com/ogham/exa/releases/download/v0.9.0/exa-linux-x86_64-0.9.0.zip
Resolving github.com (github.com)... 192.30.255.112
Connecting to github.com (github.com)|192.30.255.112|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/20060596/8958c400-a6b8-11e9-95dd-f27121ae48ee?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A/20201013/us-east-1/s3/aws4_request&X-Amz-Date=20201013T041102Z&X-Amz-Expires=300&X-Amz-Signature=aa53c10347e77a2cb1114d820e6f8b75f1372db887f4dd1e95b6e4b07b5f5d2c&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=20060596&response-content-disposition=attachment; filename=exa-linux-x86_64-0.9.0.zip&response-content-type=application/octet-stream [following]
--2020-10-13 12:11:02--  https://github-production-release-asset-2e65be.s3.amazonaws.com/20060596/8958c400-a6b8-11e9-95dd-f27121ae48ee?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A/20201013/us-east-1/s3/aws4_request&X-Amz-Date=20201013T041102Z&X-Amz-Expires=300&X-Amz-Signature=aa53c10347e77a2cb1114d820e6f8b75f1372db887f4dd1e95b6e4b07b5f5d2c&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=20060596&response-content-disposition=attachment; filename=exa-linux-x86_64-0.9.0.zip&response-content-type=application/octet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.217.32.12
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.217.32.12|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 675661 (660K) [application/octet-stream]
Saving to: ‘exa-linux-x86_64-0.9.0.zip’

100%[===============================================================================================>] 675,661      597KB/s   in 1.1s   

2020-10-13 12:11:04 (597 KB/s) - ‘exa-linux-x86_64-0.9.0.zip’ saved [675661/675661]

3.解压部署

代码语言:javascript复制
➜  ~ unzip exa-linux-x86_64-0.9.0.zip 
Archive:  exa-linux-x86_64-0.9.0.zip
  inflating: exa-linux-x86_64        
➜  ~ cp exa-linux-x86_64 /usr/local/bin/exa
报错解决

libc.so.6报错

➜ ~ exa exa: /usr/lib64/libc.so.6: version `GLIBC_2.18' not found (required by exa) 解决方法:

➜ ~ tar zxf glibc-2.18.tar.gz ➜ ~ cd glibc-2.18/ ➜ glibc-2.18 mkdir build ➜ glibc-2.18 cd build/ ➜ build ../configure --prefix=/usr ➜ build make install

使用

命令语法

➜ build exa --help Usage: exa [options] [files...]

-?, --help show list of command-line options -v, --version show version of exa

DISPLAY OPTIONS -1, --oneline display one entry per line -l, --long display extended file metadata as a table -G, --grid display entries as a grid (default) -x, --across sort the grid across, rather than downwards -R, --recurse recurse into directories -T, --tree recurse into directories as a tree -F, --classify display type indicator by file names --colo[u]r=WHEN when to use terminal colours (always, auto, never) --colo[u]r-scale highlight levels of file sizes distinctly

FILTERING AND SORTING OPTIONS -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 SORT_FIELD which field to sort by --group-directories-first list directories before other files -D, --only-dirs list only directories -I, --ignore-glob GLOBS glob patterns (pipe-separated) of files to ignore --git-ignore Ignore files mentioned in '.gitignore' Valid sort fields: name, Name, extension, Extension, size, type,

代码语言:javascript复制
                          modified, accessed, created, inode, and none.
                          date, time, old, and new all refer to modified.

LONG VIEW OPTIONS -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 -S, --blocks show number of file system blocks -t, --time FIELD which timestamp field to list (modified, accessed, created) -u, --accessed use the accessed timestamp field -U, --created use the created timestamp field --time-style how to format timestamps (default, iso, long-iso, full-iso) --git list each file's Git status, if tracked or ignored -@, --extended list each file's extended attributes and sizes

0 人点赞