nronzel/pdir
Pretty print directory structure.
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.
Made with Zig v0.14
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.
git clone https://github.com/nronzel/pdir
cd pdir
zig build -Doptimize=ReleaseSafe
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]
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:
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.