Outputs a Tree-like representation from strings. No actual files required!

Readme

TreeLike

Test Release

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] [TREE-STRUCTURE]

Prints a tree-like representation of the input.

Options

  • -h, --help: Show help message and exit.
  • -V, --version: Show the version number 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.
  • -r, --root-path PATH: Use PATH to change the name of the root node (default: .). N/A if --no-root-dot is enabled.
  • -D, --no-root-dot: Do not display a root element.

Installation

Homebrew

Install via Homebrew:

brew tap chenasraf/tap
brew install treelike

Direct Download

  1. Go to the Latest Release page.

  2. Download the appropriate binary archive for your platform:

    • Windows: treelike-windows-amd64.tar.gz
    • macOS: treelike-darwin-amd64.tar.gz
    • Linux: treelike-linux-amd64.tar.gz
  3. Extract the tar:

    tar -xzf treelike-darwin-amd64.tar.gz  # macOS
    tar -xzf treelike-linux-amd64.tar.gz  # Linux
    
  4. Make the binary executable (if necessary):

    chmod +x treelike
    
  5. Move the binary to a directory in your PATH:

    mv treelike /usr/local/bin/treelike
    

From Source

  1. Clone the repository:

    git clone https://github.com/chenasraf/treelike.git
    
  2. Navigate to the project directory:

    cd treelike
    
  3. 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!

Buy Me a Coffee at ko-fi.com

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.