Skip to content

morinokami/ptree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

83 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ptree

ptree prettifies tree command with emojis like this:

$ ptree
πŸ“ .
β”œβ”€β”€ πŸ€– binary.bin
β”œβ”€β”€ πŸ“„ document.txt
β”œβ”€β”€ 🦏 javascript.js
β”œβ”€β”€ πŸ“ markdown.md
β”œβ”€β”€ πŸͺ perl.pl
β”œβ”€β”€ 🐍 python.py
└── πŸ¦€ rust.rs

0 directory, 7 files

Installation

$ npm install -g @shf0811/ptree

Usage

  • List contents of directories:
$ ptree .
πŸ“ .
β”œβ”€β”€ πŸ“ bar
β”‚   └── πŸ“„ baz.ts
└── πŸ“„ foo.js

1 directory, 2 files
  • Specify the maximum display depth of the directory tree:
$ ptree --level 1 .
πŸ“ .
β”œβ”€β”€ πŸ“ bar
└── πŸ“„ foo.js

1 directory, 1 file
  • Specify the emojis to show:
$ ptree --emojis '{".js": "🦏", ".ts": "πŸ¦•"}' .
πŸ“ .
β”œβ”€β”€ πŸ“ bar
β”‚   └── πŸ¦• baz.ts
└── 🦏 foo.js

1 directory, 2 files
  • List only directories:
$ ptree --dir .
πŸ“ .
└── πŸ“ bar

1 directory
  • List only those files that matches the given pattern:
$ ptree --include 'foo*' .
πŸ“ .
β”œβ”€β”€ πŸ“ bar
└── πŸ“„ foo.js

1 directory, 1 file
  • List only those files that doesn't match the given pattern:
$ ptree --exclude 'foo*' .
πŸ“ .
└── πŸ“ bar
    └── πŸ“„ baz.ts

1 directory, 1 file
  • Show help:
$ ptree --help
ptree <path> [options]

Options:
      --version  Show version number                                   [boolean]
  -a, --all      Print all files and directories including those starting with a
                  dot                                 [boolean] [default: false]
  -d, --dir      Print only directories               [boolean] [default: false]
  -e, --emojis   Mapping of file extensions to emojis   [string] [default: "{}"]
  -l, --level    Maximum depth to traverse          [number] [default: Infinity]
  -i, --include  Include files matching this pattern                    [string]
  -x, --exclude  Exclude files matching this pattern                    [string]
  -h, --help     Show help                                             [boolean]

Customization

You can specify the emojis to use beforehand by creating a config file named .ptree.json in your home folder like this:

$ cat ~/.ptree.json 
{
  "emojis": {
    ".js": "🦏",
    ".ts": "πŸ¦•"
  }
}

Now you don't have to use the option each time:

$ ptree .
πŸ“ .
β”œβ”€β”€ πŸ“ bar
β”‚   └── πŸ¦• baz.ts
└── 🦏 foo.js

1 directory, 2 files

About

tree command prettified with emojis🌲

Resources

License

Stars

Watchers

Forks

Packages

No packages published