Notes - Generate trees from markdown with gtree
Checking out gtree. This caught my attention because it is for generating tree listings with markdown. Sometimes I want to have a tree in my notes.
It is not a replacement for the tree command. Rather, this is for generating trees from a markdown list.
Install
I am just grabbing the .deb and running it through gdebi. Releases here.
Usage
The simpilest way is to create a markdown file of a list and then use gtree to generate that list into a tree.
For this example I created tree.md. Its contents:
- Starting my tree
- Point 1
- Point 2
- Point 3
- Sub point 1
- Sub point 2
- Sub point 3
Now I can tell gtree to generate the contents of the file.
gtree output -f tree.md
It will then print in the terminal.
Starting my tree
├── Point 1
├── Point 2
└── Point 3
├── Sub point 1
├── Sub point 2
└── Sub point 3
Creating directories
Using gtree you can also give it a markdown list and tell it to generate those directories. So, if you wanted:
- Parent
- Child
- Child
- grandchild
- grandchild
You can then pass that to gtree and it will literally create those directories, along with the sub-directories with the mkdir flag.
For this example, we name the file tree-dirs.md and then run:
gtree mkdir -f tree-dirs.md
https://pkg.go.dev/github.com/ddddddO/gtree#readme-mkdir-subcommand
Web
The most interesting part is that the dev has a web server and makes it easy to create a tree from markdown.
This is rad.
It is similar to tools for generating tables in markdown.
You can access it here without installing gtree:
https://ddddddo.github.io/gtree/
For example, I can create a markdown list like this:
- Data backups
- 📂 nas
- media
- cloud files
- projects
- 📂 server
- docker config data
- compose files
- volumes
- 📂 nas
And it will create this for me:
Data backups
├── 📂 nas
│ ├── media
│ ├── cloud files
│ └── projects
└── 📂 server
├── docker config data
├── compose files
└── volumes
If gtree is installed, you can run this command and it will open your browser to the website for generating a tree.
gtree w
- - - - -
Did you like this post? Give it an upvote by clicking on the arrows below! Sending me an upvote is like you and I giving each other a high five.
🙏 😎
Thank you for reading! If you would like to comment on this post you can start a conversation on the Fediverse. Message me on Mastodon at @cinimodev@masto.ctms.me. Or, you may email me at blog.discourse904@8alias.com. This is an intentionally masked email address that will be forwarded to the correct inbox.If you enjoy the random stuff I write here, post to Mastodon, or watch on YouTube, and are feeling generous, I am open to tips of Ko-fi.