• Stars
    star
    454
  • Rank 96,373 (Top 2 %)
  • Language
    Rust
  • License
    Other
  • Created over 4 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Print a list of paths as a tree of paths 🌳

as-tree

Build Status

Print a list of paths as a tree of paths.

For example, given:

dir1/foo.txt
dir1/bar.txt
dir2/qux.txt

it will print:

.
β”œβ”€β”€ dir1
β”‚   β”œβ”€β”€ foo.txt
β”‚   └── bar.txt
└── dir2
    └── qux.txt

This tool is particularly useful when used with find or fd to produce such a list of files. It's similar in spirit to tree, but find and fd tend to be more powerful when it comes to controlling which files to list.

Inspired by this feature request.

Install

There are pre-built binary releases in the Releases tab.

This project is written in Rust and builds under both Bazel and Cargo.

To install from source using Cargo:

cargo install -f --git https://github.com/jez/as-tree

To install from source using Bazel:

git clone https://github.com/jez/as-tree
cd as-tree
make install

Usage

❯ as-tree --help
Print a list of paths as a tree of paths.

Usage:
  as-tree [options] [<filename>]

Arguments:
  <filename>        The file to read from. When omitted, reads from stdin.

Options:
  --color (always|auto|never)
                    Whether to colorize the output [default: auto]
  -f                Prints the full path prefix for each file.
  -h, --help        Print this help message

Example:
  find . -name '*.txt' | as-tree

Example

This tool is particularly useful with tools like fd which can prune the list of files to print better than tree can alone.

❯ fd --exclude test | as-tree
.
β”œβ”€β”€ LICENSE.md
β”œβ”€β”€ Makefile
β”œβ”€β”€ README.md
β”œβ”€β”€ WORKSPACE
β”œβ”€β”€ bazel
β”œβ”€β”€ main
β”‚   β”œβ”€β”€ BUILD
β”‚   └── main.cc
β”œβ”€β”€ third_party
β”‚   β”œβ”€β”€ BUILD
β”‚   β”œβ”€β”€ externals.bzl
β”‚   └── spdlog.BUILD
└── tools
    β”œβ”€β”€ BUILD
    β”œβ”€β”€ clang.bzl
    └── scripts
        β”œβ”€β”€ build_compilation_db.sh
        └── generate_compdb_targets.sh

Developing

Running the tests requires Bazel. The ./bazel shell script in this repo will download and cache a specific version of Bazel for you. From there, Bazel knows how to install all the dependencies it needs to build this project (including a Rust toolchain).

# Run the tests:
./bazel test --test_output=errors //test

# To add a test, create two files:
#
# - test/fixtures/foo.txt
# - test/fixtures/foo.txt.exp
#
# The first file is the input to feed to `as-tree`, and the second is the
# expected output of `as-tree` on that input

# Update all the tests:
./bazel test //test:update

# When you add a new dependency, you'll need to add it with Bazel too:
cargo install cargo-raze # (one time setup)
cd third_party/cargo
cargo raze

TODO(jez)

  • rustfmt / buildifier / shellcheck in CI
  • Only use box drawing characters if the locale supports it
    • See man locale, LC_CTYPE=C tree
  • Add a -0 flag to support files with newlines in their name
    • Seriously why is this allowed?

More Repositories

1

vim-as-an-ide

Workshop on how to use Vim Plugins.
Vim Script
1,952
star
2

pandoc-starter

πŸ“„ My pandoc markdown templates and makefiles
TeX
525
star
3

tufte-pandoc-css

Starter files for using Pandoc Markdown with Tufte CSS
CSS
311
star
4

git-heatmap

πŸ“Š Display a heatmap for oft-edited files
Shell
292
star
5

vim-superman

Read Unix man pages faster than a speeding bullet!
Vim Script
190
star
6

pandoc-markdown-css-theme

CSS files and a template for using Pandoc to generate standalone HTML files
CSS
155
star
7

pandoc-sidenote

Convert Pandoc Markdown-style footnotes into sidenotes
Haskell
136
star
8

dotfiles

My personal collection of configuration files.
Shell
122
star
9

vim-better-sml

πŸŽ‰ Enjoy writing SML within Vim
Vim Script
101
star
10

tufte-pandoc-jekyll

A Jekyll theme for using Tufte CSS with Jekyll + Pandoc
SCSS
66
star
11

git-madge

πŸš€ Git-aware madge wrapper
Shell
65
star
12

hpstr-theme

A Medium-like Octopress theme based on the HPSTR Jekyll theme.
CSS
63
star
13

tunemachine

🎢 A time machine for your Spotify tunes!
CoffeeScript
62
star
14

calz

πŸ“† A natural language alternative to Unix 'cal'
Haskell
59
star
15

bask

😎 Bask in the convenience of a task runner for bash
Shell
58
star
16

vim-github-hub

A Vim filetype plugin for github/hub ⚑
Vim Script
49
star
17

latex-solarized

Provides three LaTeX packages for using the Solarized theme in LaTeX code listings.
TeX
29
star
18

stargaze

⭐ Gaze at repos you've starred
Shell
20
star
19

resume

My resume, written in XeTeX.
TeX
14
star
20

latex-hw-template

LaTeX template useful for formatting homework assignments
TeX
13
star
21

blog

an Octopress blog by Jake Zimmerman
Liquid
13
star
22

cmu-latex-hw-template

A LaTeX template for homework assignments, used widely at CMU.
TeX
12
star
23

pandoc-markdown-jekyll-theme

CSS
10
star
24

viewjrnl

Shell script to group jrnl entries by date and add color.
Shell
7
star
25

bin

My collection of personal scripts. They're not documented and often break. Ask if you have questions.
Shell
7
star
26

talks

πŸ’¬ Slides and descriptions for talks I've given
TeX
6
star
27

starter-zshrc

You should really consider switching to zsh!
Shell
6
star
28

multi-sub

Substitute a pattern with a replacement on specific lines
OCaml
6
star
29

vim-ispc

Vim syntax highlighting for ISPC.
Vim Script
6
star
30

barchart

πŸ“Š Print a bar chart from the command line
Rust
5
star
31

ragel-bison-parser-sandbox

A small parser for the lambda calculus in C++ using Bazel, Ragel, and Bison
C++
5
star
32

cmd-queue

A simple queueing service for CMU students.
CoffeeScript
5
star
33

diff-locs

List the file locations involved in a diff
Haskell
5
star
34

smlnj-viscomp-example

An example of how to use SML/NJ's Visible Compiler APIs
Standard ML
4
star
35

symbol

πŸ”¨ A build tool for Standard ML
Shell
4
star
36

stlc-infer

A small interpretter for the simply typed lambda calculus, with type inference
Haskell
4
star
37

multi-grep

Search for a pattern on specific lines
Standard ML
3
star
38

tsim

A Turing machine simulator in SML
Standard ML
3
star
39

rust-lc-interp

Toy interpreter for the lambda calculus to explore Rust
Rust
2
star
40

auditors-webhook

Post commit review using Auditors
CoffeeScript
2
star
41

jez.github.io

A collection of my projects, contact info, and life.
CSS
2
star
42

google-apps-cmu-login

Bare bone demo of how to use Google OAuth2 with Python Social Auth in Django to authenticate by Andrew account.
Python
2
star
43

collate

Command line filter for collating the top and bottom halves of a file
Haskell
1
star
44

awkward-bun

Python
1
star
45

marauder

CSS
1
star
46

spacer

Blank macOS app to take up space
Rust
1
star
47

thoughts

A collection of some essays and longer-form writings.
CSS
1
star
48

flac-post-tag

Generate "post tag system" traces
Haskell
1
star
49

language-communities-on-github

TeX
1
star
50

th-portfolios

Simple app to coordinate uploading and downloading of resumes and profile information at TartanHacks 2014
JavaScript
1
star
51

as-tree-cpp

Print a list of paths as a tree of paths 🌳
Starlark
1
star
52

penndot-dash

A dashboard I designed for one of my class projects
1
star
53

homebrew-formulae

A Homebrew tap for my personal CLI tools
Ruby
1
star
54

JBooks

Java
1
star
55

jquery-lab

Simple game demo in jQuery to demonstrate some principles of frontend development.
JavaScript
1
star
56

vim-sorbet

Vim Script
1
star
57

collate-rs

Rust
1
star