Created
November 4, 2020 14:53
-
-
Save 1lastBr3ath/a41bf7d800d9ab0f6134779db046718a to your computer and use it in GitHub Desktop.
GitHub pre-commit hook to generate tree structure of documents along with hyperlink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
README="${1:-README.md}" | |
HEAD="$(head -n5 "$README")" | |
cat > "$README" <<< "$HEAD" | |
#echo "## Table of Contents" >> "$README" | |
tree -f --dirsfirst --noreport -I README.md | sed -r '1d; s#\.\/(.+)#[\1]\(<./\1\>)#g; s#\[[^]/]+\/#[#g; s/$/ /g' >> "$README" | |
git add "$README" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment