A modern CLI tool for visualizing directory structures with advanced filtering and display options.
- 🎨 Colorized output (directories in blue, files in cyan)
- 📏 Configurable directory traversal depth
- 🔍 Multiple filtering options:
- File extensions
- Regular expression patterns
- Hidden files
- Directories/files only
- 📊 File size display
- 📅 Last modified dates
- 🔄 Multiple sorting options
- 💾 Save output to file
- ⚡ Performance optimized
npm install -g file-tree-clitree [options] [directory]If no directory is specified, the current directory will be used.
# Display tree of current directory
tree
# Display tree of specific directory
tree /path/to/directory
# Show tree with file sizes
tree -s
# Show only JavaScript and TypeScript files
tree --ext js,ts
# Show files modified dates and sizes
tree -s -m# Show only directories, sorted by name
tree --dirs-only --sort name
# Show only JavaScript files and their sizes
tree --ext js -s
# Show tree with custom depth and excluded directories
tree -d 3 -e "dist,coverage"
# Show all files (including hidden) sorted by size
tree -a --sort size
# Export tree to a file
tree -o output.txt| Option | Description |
|---|---|
-d, --max-depth <number> |
Maximum depth to traverse |
-a, --all |
Show hidden files |
-e, --exclude <items> |
Comma-separated list of directories to exclude |
-s, --show-size |
Show file sizes |
-m, --modified |
Show last modified date |
-f, --pattern <pattern> |
Filter items by regex pattern |
--ext <extensions> |
Filter by file extensions (comma-separated) |
--sort <type> |
Sort items by: name, size, or date |
-r, --reverse |
Reverse sort order |
--dirs-only |
Show only directories |
--files-only |
Show only files |
-o, --output <file> |
Save output to file |
The tool provides a structured view of your directory:
Directory
├── src
│ ├── index.ts [2.5KB] 2024-01-15
│ └── utils.ts [1.2KB] 2024-01-14
└── package.json [0.8KB] 2024-01-10
- Clone the repository:
git clone https://github.com/devxprite/file-tree-cli.git- Install dependencies:
npm install- Build the project:
npm run build- Link for local development:
npm linkContributions are welcome! Please feel free to submit a Pull Request.
MIT