List contents of directories in a tree-like format with colorization and lots of options.
I frequently need a tree-style directory listing charts to include in my GitHub
doc files. But the native windows tree.com
implementation is far from perfect, and the Linux clone Tree for Windows
renders the tree with legacy ASCII
characters.
So I decided to spend a couple of hours to write this wrapper with color highlighting and proper leafs rendering support.
This module uses Tree for Windows in order to get the initial directory structure and then colorizes its output and renders the unicode representation.
Make sure to download the Tree for Windows and make it accessible through your system PATH
variable
Install via Chocolatey: cinst tree
Get-ChildItemTree
Understands all of its Linux tree
counterpart, command line switches. So, feel free to read the official docs for more info.
PS> Install-Module Tree
If you want the alias
tree
to work properly, addImport-Module Tree
to your Powershell profile config.
Use Get-ChildItemTree --help
for help.
- The path is optional
- Network paths supported
\\server.local\Path
# Generate the tree
# -a include hidden files
# -I exclude .git folder
PS>Get-ChildItemTree D:\Path -a -I .git
.
├── FolderOne
│ ├── LICENSE
│ ├── archive.rar
│ └── text.txt
├── FolderThree
│ ├── FolderTwo
│ │ ├── SRC
│ │ │ ├── picture.png
│ │ │ └── unknown.yyy
│ │ ├── executable.ps1
│ │ └── unknown.yyy
│ └── text.md
└── FolderTwo
├── InnerFolder
│ └── unknown.yyy
├── executable.ps1
└── unknown.yyy
# -h Print the size of each file in a human readable way
# -p Print the file type and permissions for each file
Get-ChildItemTree D:\Path -a -h -p