Skip to content

Instantly share code, notes, and snippets.

@zeddee
Last active December 30, 2019 05:18
Show Gist options
  • Save zeddee/dee38100ee1395da66f30fdc366e304f to your computer and use it in GitHub Desktop.
Save zeddee/dee38100ee1395da66f30fdc366e304f to your computer and use it in GitHub Desktop.

The tree <location> command lists the contents of <location> as an ASCII-formatted directory tree.

For example, to:

  • List the contents of the current working directory ($(pwd)),
  • List all hidden files and folders,
  • Exclude the node_modules and .git directories,

Run:

tree -a -I 'node_modules|.git' $(pwd)

Important options:

Option Description
-a Includes hidden files in list.
-d Lists only directories.
-L <int> Lists contents of <location> up to <int> levels deep.
-I <pattern> Exclude files that match pattern. Can use regexp (not clear if PCRE or others).
-P <pattern> Include files that match pattern. Can use regexp (not clear if PCRE or others).
<path> Set this as . to list the contents of the current working directory. Set as $(pwd) to list contents of the current working directory, and print the path at the top of the tree diagram.

Output:

/User/userland/working/library
├── .dockerignore
├── .env
├── .eslintrc.json
├── .gcloudignore
├── .github
│   ├── ISSUE_TEMPLATE
│   │   ├── bug_report.md
│   │   └── feature_request.md
│   └── pull_request_template.md
├── .gitignore
├── .nvmrc
├── .travis.yml
├── CONTRIBUTING.md
├── Dockerfile
├── LICENSE
├── Procfile
├── README.md
├── app.json
├── app.yaml
├── bin
│   ├── install_customizations
│   └── update_gae_pkg
├── config
│   ├── index.yaml
│   └── strings.yaml
├── custom
│   └── README.md
├── layouts
│   ├── categories
│   │   └── default.ejs
│   ├── errors
│   │   ├── 403.ejs
│   │   ├── 404.ejs
│   │   └── 500.ejs
│   ├── pages
│   │   ├── categories.ejs
│   │   ├── index.ejs
│   │   ├── move-file.ejs
│   │   └── search.ejs
│   ├── partials
│   │   ├── branding.ejs
│   │   ├── breadcrumb.ejs
│   │   ├── childrenList.ejs
│   │   ├── folderList.ejs
│   │   ├── footer.ejs
│   │   ├── head.ejs
│   │   ├── header.ejs
│   │   ├── landingModule.ejs
│   │   ├── nav.ejs
│   │   ├── search.ejs
│   │   ├── sectionList.ejs
│   │   ├── siblingList.ejs
│   │   ├── userTools.ejs
│   │   └── warning.ejs
│   └── playlists
│       ├── index.ejs
│       └── leaf.ejs
├── nytimes-library-try2-1f2845da9f22.json
├── package-lock.json
├── package.json
├── pbcopy
├── public
│   ├── .gitignore
│   ├── css
│   │   ├── errors.css
│   │   ├── style.css
│   │   └── style.css.map
│   ├── images
│   │   ├── icon-logo-cc-license.txt
│   │   ├── icon-logo.svg
│   │   └── library.ico
│   └── scripts
│       └── main.js
├── server
│   ├── auth.js
│   ├── cache
│   │   └── store.js
│   ├── cache.js
│   ├── csp.json
│   ├── docs.js
│   ├── formatter.js
│   ├── index.js
│   ├── list.js
│   ├── logger.js
│   ├── move.js
│   ├── routes
│   │   ├── categories.js
│   │   ├── errors.js
│   │   ├── pages.js
│   │   ├── playlists.js
│   │   ├── readingHistory.js
│   │   └── userInfo.js
│   ├── search.js
│   ├── urlParser.js
│   ├── userAuth.js
│   └── utils.js
├── styles
│   ├── partials
│   │   ├── _custom.scss
│   │   ├── _theme.scss
│   │   ├── _vars.scss
│   │   └── core
│   │       ├── _base.scss
│   │       ├── _categories.scss
│   │       ├── _furniture.scss
│   │       ├── _mixins.scss
│   │       └── _pages.scss
│   └── style.scss
└── test
    ├── fixtures
    │   ├── datastoreResponses.json
    │   ├── driveListing.js
    │   ├── sheetBuffer.buf
    │   ├── supportedFormats.html
    │   └── testHTML.json
    ├── functional
    │   ├── pages.test.js
    │   ├── playlists.test.js
    │   ├── readingHistory.test.js
    │   └── userAuth.test.js
    ├── unit
    │   ├── cache.test.js
    │   ├── docs.test.js
    │   ├── errors.test.js
    │   ├── htmlProcessing.test.js
    │   ├── list.test.js
    │   ├── move.test.js
    │   ├── playlists.test.js
    │   └── search.test.js
    └── utils
        ├── bootstrap.js
        ├── googleMock.js
        ├── index.js
        └── updateSupportedFormats.js

26 directories, 108 files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment