TreeLike
TreeLike is a command-line tool that prints a tree-like representation of the input. It can read from a file, standard input, or command-line arguments.
Usage
treelike [OPTIONS] [PATH]
Prints a tree-like representation of the input.
Options
-h, --help: Show help message and exit.-f, --file FILE: Read from FILE.-, --stdin: Read from stdin.-c, --charset CHARSET: Use CHARSET to display characters (utf-8, ascii).-s, --trailing-slash: Display trailing slash on directory.-p, --full-path: Display full path.-D, --no-root-dot: Do not display a root element.
Installation
From Releases
- Go to the Releases page.
- Download the appropriate binary for your platform:
- Windows:
treelike-windows-amd64.exe - macOS:
treelike-darwin-amd64 - Linux:
treelike-linux-amd64
- Windows:
- Make the binary executable (if necessary):
chmod +x treelike-darwin-amd64 # For macOS chmod +x treelike-linux-amd64 # For Linux - Move the binary to a directory in your PATH:
mv treelike-darwin-amd64 /usr/local/bin/treelike # For macOS mv treelike-linux-amd64 /usr/local/bin/treelike # For Linux
From Source
- Clone the repository:
git clone https://github.com/chenasraf/treelike.git - Navigate to the project directory:
cd treelike - Build the project:
go build -o treelike treelike.go
Examples
Tree File
usr
local
bin
sh
bash
zsh
fish
sbin
sysctl
tcpdump
Reading from a file
treelike -f example.txt
Outputs:
.
└── usr
├── local
├── bin
│ ├── sh
│ ├── bash
│ ├── zsh
│ └── fish
└── sbin
├── sysctl
└── tcpdump
Reading from stdin
cat example.txt | treelike -
Displaying full path
treelike -f example.txt -p
Outputs:
.
└── ./usr
├── ./usr/local
├── ./usr/bin
│ ├── ./usr/bin/sh
│ ├── ./usr/bin/bash
│ ├── ./usr/bin/zsh
│ └── ./usr/bin/fish
└── ./usr/sbin
├── ./usr/sbin/sysctl
└── ./usr/sbin/tcpdump
Without root dot
treelike -f example.txt -D
Outputs:
usr
├── local
├── bin
│ ├── sh
│ ├── bash
│ ├── zsh
│ └── fish
└── sbin
├── sysctl
└── tcpdump
Using ASCII charset
treelike -f example.txt -c ascii
Outputs:
.
`-- usr
|-- local
|-- bin
| |-- sh
| |-- bash
| |-- zsh
| `-- fish
`-- sbin
|-- sysctl
`-- tcpdump
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
I am developing this package on my free time, so any support, whether code, issues, or just stars is very helpful to sustaining its life. If you are feeling incredibly generous and would like to donate just a small amount to help sustain this project, I would be very very thankful!
I welcome any issues or pull requests on GitHub. If you find a bug, or would like a new feature, don't hesitate to open an appropriate issue and I will do my best to reply promptly.