tree
Version 1.3
This is Cat's Eye Technologies' tree
, a command-line tool that displays an
indented directory tree, similar to "The Tree Command for Linux" except simpler.
It:
- is written in Python (tested with Python 3.9; 2.7 probably still works)
- is small and has no dependencies besides Python
- is in the public domain (see
LICENSES/Unlicense.txt
) - is really quite crude
- displays a summary of the directory structure by default (because to me, that's the point of this sort of tool: give me a conceptual overview of the directory structure at this point in the filesystem, so I can orient myself)
- never follows symbolic links
- always outputs a
/
after each directory name - doesn't have any ASCII art (yet; it might someday as the lines do make it a bit easier to "read" the tree)
- has no build/install system; either copy it to somewhere on your
search path, or alter your search path to include the
script
directory in this repo, or use some system that solves this problem, like shelf.
Usage
tree [-f|--full] [-a|--all-files] [-1|--1-line] [-c|--count]
[-w|--max-width <int>] [-x|--exclude <list>] [DIRECTORY]
If DIRECTORY is not supplied, the current directory is assumed.
The --full
option lists each file in a directory on its own line.
The --all-files
option includes files whose names begin with a
.
character, which would otherwise be hidden.
The --1-line
option lists a summary of the files in each directory
on one line, truncating the line if it is longer than the max-width.
The --count
option causes a count of files in each directory to
be display instead of listing the files themselves.
If none of those options are given, all files in a directory are listed compactly over multiple lines, in a "block".
The --max-width
option can be used to set the length of truncation
or block-wrapping. It defaults to the width of the terminal window
as returned by stty size
, if that program can be run, otherwise 75.
The --exclude
option sets the list of directory names to not descend
into (a comma-separated list). It defaults to venv
, node_modules
,
__pycache__
, and .git
.
Related work
- The Tree Command for Linux — GPL'ed and feature-bloated and has no automated build system (you're supposed to edit the Makefile by hand.)
- pyr/tree — fine if you're running OpenBSD I suppose, but I gave up on trying to port it to NetBSD and Linux and wrote this instead.
Commit History
@master
git clone https://git.catseye.tc/tree/
- Remove .reuse/dep5, move all licensing info into individual files. Chris Pressey 3 months ago
- Add logo. Chris Pressey 8 months ago
- Adjust SPDX fields to better conform to the REUSE 3.0 spec. Chris Pressey 10 months ago
- Arrange licensing info to follow the REUSE 3.0 convention. Chris Pressey 10 months ago
- Employ `shlex.quote` to deal better w/filenames containing spaces. Chris Pressey 11 months ago
- Merge pull request #1 from catseye/develop-1.2 Chris Pressey (commit: GitHub) 2 years ago
- Add .git to the list of default excludes. Chris Pressey 2 years ago
- Add very rudimentary test script. Chris Pressey 2 years ago
- Merge branch 'develop-1.2' of https://github.com/catseye/tree into develop-1.2 Chris Pressey 2 years ago
- Add `-a`|`--all-files` flag, to show files starting with `.`. Chris Pressey 2 years ago