Code on the Rocks

MIT License pub version

Developer Blog β€’ GitHub Repo β€’ Pub.dev


file_tree

Visualize the file tree of a directory 🌳

Installation

dart pub global activate file_tree

Usage

Output the file and directory tree of the current directory:

tree grow

Output:

β”œβ”€β”€ LICENSE
β”œβ”€β”€ test/
β”‚  └── file_tree_test.dart
β”œβ”€β”€ bin/
β”‚  └── file_tree.dart
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ pubspec.lock
β”œβ”€β”€ README.md

Output the file and directory tree using ASCII characters:

tree grow -a

Output:

+-- LICENSE
+-- test/
|  `-- file_tree_test.dart
+-- bin/
|  `-- file_tree.dart
+-- CHANGELOG.md
+-- pubspec.lock
+-- README.md

Output the file and directory tree and use emojis to indicate file type:

tree grow -e

Output:

β”œβ”€β”€ πŸ“„ LICENSE
β”œβ”€β”€ πŸ“ test/
β”‚  └── πŸ“„ file_tree_test.dart
β”œβ”€β”€ πŸ“ bin/
β”‚  └── πŸ“„ file_tree.dart
β”œβ”€β”€ πŸ“„ CHANGELOG.md
β”œβ”€β”€ πŸ“„ pubspec.lock
β”œβ”€β”€ πŸ“„ README.md

Limit the depth of the file tree (e.g., to 2 levels):

tree grow -d 2

Output:

β”œβ”€β”€ LICENSE
β”œβ”€β”€ test/
β”‚  └── file_tree_test.dart
β”œβ”€β”€ bin/
β”‚  └── file_tree.dart
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ pubspec.lock
β”œβ”€β”€ README.md

Include all files, ignoring .gitignore:

tree grow -A

Help

(tree grow -h)

Print out a file tree for the current directory.

Usage: tree grow [arguments]
-a, --ascii             Use only ASCII characters to draw the tree.
-e, --emojis            Add emojis to the tree to indicate file types.
-i, --include_hidden    Include hidden files in the tree
-d, --depth             Set the maximum depth of the tree (default: -1, no limit)
-A, --all               Include all files, ignoring .gitignore

Options

  • -a, --ascii: Use ASCII characters for the tree structure instead of Unicode characters.
  • -e, --emojis: Add emojis to indicate file types (πŸ“ for directories, πŸ“„ for files).
  • -i, --include_hidden: Include hidden files and directories in the tree.
  • -d, --depth: Set the maximum depth for the tree. Use -1 for unlimited depth (default).
  • -A, --all: Include all files, ignoring .gitignore rules.

Examples

Show tree with emojis, including hidden files, limited to 3 levels deep:

tree grow -e -i -d 3

Show ASCII tree of the first two directory levels:

tree grow -a -d 2

Show complete tree, including files that would normally be ignored by .gitignore:

tree grow -A

Show tree with emojis, including all files (ignoring .gitignore), and hidden files:

tree grow -e -A -i

Libraries

commands/commands
commands/grow
file_tree
View the file tree of a directory