Skip to content

Instantly share code, notes, and snippets.

@L04DB4L4NC3R
Created July 7, 2020 18:08
Show Gist options
  • Save L04DB4L4NC3R/027c97d71a2a804d99d4e5b2023e6d08 to your computer and use it in GitHub Desktop.
Save L04DB4L4NC3R/027c97d71a2a804d99d4e5b2023e6d08 to your computer and use it in GitHub Desktop.
Tree command output to markdown
#!/bin/bash
#File: tree-md
tree=$(tree -tf --noreport -I '*~' --charset ascii $1 |
sed -e 's/| \+/ /g' -e 's/[|`]-\+/ */g' -e 's:\(* \)\(\(.*/\)\([^/]\+\)\):\1[\4](\2):g')
printf "# Project tree\n\n${tree}"
@dkhill
Copy link

dkhill commented Jun 14, 2024

Thanks for providing this!! I updated my version to include a -d (directories only) and -L 4 (to go 4 levels deep).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment