Linuxメモ : 「exa」Rustで書かれたカラフルなls代替コマンドを試す
exa
exa · a modern replacement for ls

exaというRustで書かれたモダンなlsの代替コマンドを試してみる。
特徴としては下記項目が挙げられている。
- デフォルトで色分け
- 詳細なファイル情報表示
- ツリービュー
- Gitサポート
- 高速
インストール
Macならbrewでインストールできる。
$ brew install exa
または、下記リンクにmacOS 64bit用とLinux 64bit用のバイナリがあるのでダウンロードする。
ソースからビルドする方法は後述。
使い方
lsと同じように使えばよい。指定できるオプションはlsと似ている。

ヘッダ、inode、Blocks情報などを表示。

ツリービューにするには-Tまたは--treeオプションを指定する。

Gitステータスを表示するには--gitオプションを指定する(-lオプションも必要)。

ソースからビルドする場合
CentOSでソースからビルドする方法を試してみる。
ビルドにはRustが必要なので下記リンクを参考にまずはRustをインストールする。
https://www.rust-lang.org/en-US/install.htmlwww.rust-lang.org
$ curl https://sh.rustup.rs -sSf | sh
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust programming
language, and its package manager, Cargo.
It will add the cargo, rustc, rustup and other commands to Cargo's bin
directory, located at:
/home/vagrant/.cargo/bin
This path will then be added to your PATH environment variable by modifying the
profile files located at:
/home/vagrant/.profile
/home/vagrant/.zprofile
/home/vagrant/.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
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation選択肢が表示されるのでデフォルトの1を入力してリターン。
1 info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: latest update on 2017-07-20, rust version 1.19.0 (0ade33941 2017-07-17) info: downloading component 'rustc' 37.6 MiB / 37.6 MiB (100 %) 153.6 KiB/s ETA: 0 s info: downloading component 'rust-std' 55.6 MiB / 55.6 MiB (100 %) 214.4 KiB/s ETA: 0 s info: downloading component 'cargo' 3.6 MiB / 3.6 MiB (100 %) 140.8 KiB/s ETA: 0 s info: downloading component 'rust-docs' 3.5 MiB / 3.5 MiB (100 %) 249.6 KiB/s ETA: 0 s info: installing component 'rustc' info: installing component 'rust-std' info: installing component 'cargo' info: installing component 'rust-docs' info: default toolchain set to 'stable' stable installed - rustc 1.19.0 (0ade33941 2017-07-17) 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
これでRustのインストールが完了。下記ディレクトリに一連のコマンドが置かれている(ディレクトリがない場合は再ログインする)。
$ ls ~/.cargo/bin cargo rls rust-gdb rust-lldb rustc rustdoc rustup
ビルドには下記パッケージが必要なのでインストール。
$ sudo yum install libgit2 cmake
パッケージマネージャのCargoを使ってexaをインストールする。
$ cargo install --git https://github.com/ogham/exa …省略… Installing /home/vagrant/.cargo/bin/exa
これでexaが使えるようになる。
$ exa --version exa v0.7.0
以下のようにmake installする方法もあるが、この場合は/usr/local/binにインストールされるようだ。
$ git clone https://github.com/ogham/exa.git $ make install
ヘルプメッセージ
$ 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
-r, --reverse reverse the sort order
-s, --sort SORT_FIELD which field to sort by:
--group-directories-first list directories before other files
-I, --ignore-glob GLOBS glob patterns (pipe-separated) of files to ignore
Valid sort fields: name, Name, extension, Extension, size, type,
modified, accessed, created, inode, none
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
-L, --level DEPTH limit the depth of recursion
-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
-@, --extended list each file's extended attributes and sizes