exa

Tree view

exa’s tree view provides an analogue to the Unix tree command.

This is possible to a certain extent using the --recurse flag, which recurses into sub-directories to list them after listing a parent directory. It outputs a separate listing for each directory that gets discovered, one after another.

Tree view, on the other hand, displays sub-directories inside the listing of their parent directories, making it easier to visualise the directory structure and see which files are where.

exa --tree --level=2 rust/rust-ansi-parse
rust/rust-ansi-parse
├── bin
│  └── parse-ansi-codes.rs
├── Cargo.lock
├── Cargo.toml
├── README.md
├── src
│  ├── cursor.rs
│  ├── lib.rs
│  └── style.rs
├── target
│  └── debug
└── test

Metadata in the tree

You can use the --long flag to display the long view metadata next to each entry in the output. The table is formatted in the same way, except the tree structure is displayed by the filenames.

exa --tree --level=2 rust/rust-ansi-parse --long
drwxr-xr-x    - ben  8 Dec  9:03 rust/rust-ansi-parse
drwxr-xr-x    - ben  8 Dec  9:09 ├── bin
.rw-r--r--@   0 ben  8 Dec  9:09 │  └── parse-ansi-codes.rs
.rw-r--r--  764 ben  8 Dec  9:03 ├── Cargo.lock
.rw-r--r--@ 195 ben  8 Dec  9:12 ├── Cargo.toml
.rw-r--r--  109 ben  7 Dec 21:56 ├── README.md
drwxr-xr-x    - ben  7 Dec 22:45 ├── src
.rw-r--r--@ 459 ben  8 Dec  9:13 │  ├── cursor.rs
.rw-r--r--@ 405 ben  8 Dec  9:14 │  ├── lib.rs
.rw-r--r--@ 562 ben  7 Dec 23:09 │  └── style.rs
drwxr-xr-x    - ben  8 Dec  9:03 ├── target
drwxr-xr-x@   - ben  8 Dec  9:04 │  └── debug
drwxr-xr-x    - ben  7 Dec 21:58 └── test

Can I limit how deep it recurses?

Use the -L or --level command-line argument to provide a limit to the recursion depth.

A depth of 1 only list every files in the given directory, basically switching recursion off again; a depth of 2 will list the sub-directories of those directories, but no further; a depth of 3 will list the sub-directories of those, and so on.