Is there a way to represent a directory tree in a Github README.md?

后端 未结 14 1825
庸人自扰
庸人自扰 2020-12-22 17:03

In my Githubs repos documentation I want to represent a directory tree structure like this:

\"enter

14条回答
  •  执笔经年
    2020-12-22 17:43

    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.

提交回复
热议问题