Skip to content

Collapse

In software development it is a common occurrence to have files that are generated from other files.

  • Lockfiles are generated from package manifests.
  • Source maps are generated from source code.
  • Classes are generated by compilers parsing the source code.
  • Code files are generated by transpilers converting code in another language.

pls has the novel ability for you to define the collapsing rules for these derived files so that they are both listed together with their source, and also depicted in a way that emphasises their dependency relationship.

pls can also nest collapsed nodes into other collapsed nodes, forming a full tree of collapses.

Arguments

--collapse/-c can be used to turn collapsing on or off. pls enables this collapsing behaviour by default.

Examples

Terminal window
pls # or --collapse=true or -c=true

​ Cargo.toml   └─ Cargo.lock

 
Terminal window
pls --collapse=false # or -c=false

Cargo.lock  Cargo.toml

 

Configuration

Using the configuration system, you can both change the appearance of the tree and also define additional rules for collapsing in addition to the built-in ones.

Examples

Here is an example showing nested collapses. It uses simple ASCII characters to render colorful collapse trees.

.pls.yml
app_const:
tree:
pipe_space: "<magenta>|</> "
space_space: " " # should be as wide as the other entries for alignment
tee_dash: "<green>+--</> "
bend_dash: "<blue>+--</> "
specs:
- pattern: ^\.?\w{1}$
icon: file
- pattern: b
collapse:
name: a
- pattern: c
collapse:
name: b
- pattern: \.d
collapse:
name: b
- pattern: e
collapse:
name: a

​ a   +--  b   | +--  c   | +-- .d   +--  e  .pls.yml