swcarpentry / shell-novice

The Unix Shell
http://swcarpentry.github.io/shell-novice/
Other
388 stars 974 forks source link

Make file tree diagrams uniform and scripted? #1263

Open gcapes opened 2 years ago

gcapes commented 2 years ago

There are various diagrams illustrating a file tree in this lesson. Some in the main body of episode 2 which I guess were manually created, and some in the exercises which look to have been made with graphviz. Ep7 has another of the manually created diagrams. There's nothing wrong with this except when it comes to changing the lesson. It's a pain to manually recreate these drawings and is a barrier to making changes.

I've written some python using graphviz which will create diagrams from a directory tree like this. Interested in adding this to the lesson? tree-diagram.gv.pdf

nbehrnd commented 2 years ago

Depending on the depth to cover, I like to use tree because it discerns folders and files (folders may be disabled by -d) and yields a representation from which one may copy-paste the name of files and folders. It works best if the font is non-proportional.

For an illustration, the shell-lesson-data (fetched from here) were decompressed to the desktop. As an example to reach two levels deep (-L 2):

~/Desktop/shell-lesson-data$ tree -L 2 -d
.
├── exercise-data
│   ├── animal-counts
│   ├── creatures
│   ├── proteins
│   └── writing
└── north-pacific-gyre

6 directories

Or one providing a quick report for files and folders:

~/Desktop/shell-lesson-data$ tree exercise-data/
exercise-data/
├── animal-counts
│   └── animals.csv
├── creatures
│   ├── basilisk.dat
│   ├── minotaur.dat
│   └── unicorn.dat
├── numbers.txt
├── proteins
│   ├── cubane.pdb
│   ├── ethane.pdb
│   ├── methane.pdb
│   ├── octane.pdb
│   ├── pentane.pdb
│   └── propane.pdb
└── writing
    ├── haiku.txt
    └── LittleWomen.txt

4 directories, 13 files
gcapes commented 2 years ago

tree certainly makes it easy to create the representations and is already used in various places in the lesson, but maybe isn't suitable to replace all the graphical representations which are probably useful representations for many novices.

braunms commented 2 years ago

I like the idea of generating the file structure diagrams via a script. Alternatively, I would like to suggest draw.io (https://app.diagrams.net/) In my opinion it is a very intuitive web-based tool for creating nice diagrams very fast. The project file can be stored inside the png file header. This way, the png file can be taken to reload the project in draw.io

tree-diagram draw io