-
Notifications
You must be signed in to change notification settings - Fork 6
/
README.sh
executable file
·44 lines (37 loc) · 1.37 KB
/
README.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# creates drivers/sbin/README.md based upon directory contents
set -e
echo '''# kerchow
kerchow is a collection of shortcuts/binfiles/scripts to speed up common tasks
these are intended to be added to your `PATH` to shorthand various workflows - _see `setup.zsh` for an example_
each script is noted below alongside a brief description of what it does. where applicable, example outputs are shown
---
''' > README.md
scriptsdir=$(git rev-parse --show-toplevel)/sbin
cd "${scriptsdir}"
for file in *
do
if [ "${file}" != "README.md" ] && [ "${file}" != "matrix" ]
then
filetype=$(file "${file}")
if [[ "${filetype}" == *"script text executable"* ]]; then
definition=$(cat "$file" | sed -n '2p')
description=$(echo "${definition}" | sed 's/# //g')
echo "## ${file}" >> ../README.md
echo "" >> ../README.md
echo "[:link:](sbin/${file}) _${description}_" >> ../README.md
echo "" >> ../README.md
example_file="${file}.md"
if [ -f "${example_file}" ]; then
echo "<details><summary>example:</summary>" >> ../README.md
echo "" >> ../README.md
example_content=$(cat "${example_file}")
echo "\`\`\`" >> ../README.md
echo "${example_content}" >> ../README.md
echo "\`\`\`" >> ../README.md
echo "</details>" >> ../README.md
echo "" >> ../README.md
fi
fi
fi
done