DEV Community

box
box

Posted on

Display Dir Structure in Tree Format.

Environment

  • Mac

    • CPU: Apple M4
    • OS: Sequoia 15.1.1
  • Zsh

    • Version: 5.9
  • Homebrew

    • Version: 4.4.10

Sample

Run the following command to create the sample directories and files.

mkdir -p ./dir1/dir2
touch ./file0.txt ./dir1/file1.txt ./dir1/dir2/file2.txt
Enter fullscreen mode Exit fullscreen mode

Flow

  1. Install tree command.

    brew install tree
    

    We can check the version of this command by running the following command.

    tree --version
    

    As of the time of writing, the version is 2.2.1.

  2. Run the command.

    tree
    

    The result is as follow.

    .
    ├── dir1
    │   ├── dir2
    │   │   └── file2.txt
    │   └── file1.txt
    └── file0.txt
    

Manual

Running the following command will display the manual page for the tree command in Zsh.

man tree
Enter fullscreen mode Exit fullscreen mode

After reading, press the q key to return to Zsh.

The source for tree v2.2.1 manual is here.

Top comments (0)