pdir ("pretty directory" or "print directory") is a lightweight, Zig-based implementation of the Linux tree command. It provides a visual representation of directory structures, using 📁 icons for directories and 📄 icons for files.
Note
This is not a 1:1 re-implementation of the tree
utilities functionalities.
- Customizable directory path and depth
- Intuitive visual representation of file system structures
- Provides count of directories, files, sym-links, and others
- Simple and efficient command-line interface
Made with Zig v0.15.1
Caution
This was only tested on Linux. Please open issues if you use the Mac version. Windows users, you will need to clone the repo and build this yourself.
- Clone the repository:
git clone https://github.com/nronzel/pdir
cd pdir
- Build the binary:
zig build -Doptimize=ReleaseSmall
OR
Download the latest release binary
Be sure to add the binary to a directory that is on your $PATH
. See quick setup
pdir [directory] [depth]
- directory: Optional. Path to the directory you want to visualize. Defaults to the current working directory.
- depth: Optional. Maximum depth of directory traversal. Defaults to 2.
With the default depth of 2, it will show the current directory and 1 level of nested directories.
pdir ~/Documents 3
This command will display the directory structure of ~/Documents up to a depth of 3 levels.
pdir
This command will display the directory structure of the current working directory up to a depth of 2 levels.
To use pdir from anywhere in your terminal:
- Copy the binary to a directory that is in your PATH:
cp ./zig-out/bin/pdir ~/.local/bin/
On Linux, you can view the directories in your path by running:
echo $PATH
Now you can run pdir from any location in your terminal.
Run the included tests:
zig test src/main.zig
This was written for educational reasons get more familiar with Zig. It is not a 1:1 of the Linux
tree
command.