In my Githubs repos documentation I want to represent a directory tree structure like this:
For those who want a quick solution:
There is a way to get a output to the console similar to the output from tree, by typing the following command into your terminal:
ls -R YOURFOLDER | grep ':$' | sed -e 's/:$//' -e 's/[^\/]*\//| /g' -e 's/| \([^|]\)/|–– \1/g'
This alternative is mentioned in this documentation: https://wiki.ubuntuusers.de/tree/
Then the output can be copied and encapsuled inside a .md file with code block back tics, like mentioned in Jonathas B.C.'s answer.
But be aware that it also outputs all node modules folders in a node project. And in tree you can do something like
tree -I node_modules
to exlude the node modules folder.
Not directly, no. You'd have to hand create it and put it in yourself. Assuming you are using a *nix box locally and are using utf, then tree will generate it nicely (I believe that is what generated the example you used above).
Assuming you mean the readme.md
as the documentation target, then I think the only way you could automate it would be a git pre-commit hook that ran tree
and embedded it into your readme file. You'd want to do a diff to make sure you only updated the readme if the output changed.
Otoh if you are maintaining seperate docs via github pages, then what you could do, is switch to using jekyll (or another generator) locally and pushing the static pages yourself. Then you could potentially implement the changes you want either as a plugin / shell script* / manual changes (if they won't vary much), or use the same method as above.
*If you integrate it into a commit hook, you can avoid adding any extra steps to changing your pages.
The best way to do this is to surround your tree in the triple backticks to denote a code block. For more info, see the markdown docs: http://daringfireball.net/projects/markdown/syntax#code
You can also check this tree-extended package. It can be used as a command line app by using node >= 6.x.
It is very similar to tree
but also has the option of configuring the max deep in the tree, that is one of the awful things of it. Also you can filter by using .gitignore
file.
Insert command tree in bash.
Also, there is a DOS comnand "tree". You can displays directory paths and files in each subdirectory with command:
tree /F
https://web.csulb.edu/~murdock/tree.html
I got resolver the problem in this way:
tree
in bash.Example
Example
4. See the output and be happy =)