Skip to content

Instantly share code, notes, and snippets.

@sportebois
Created February 10, 2018 18:38
Show Gist options
  • Save sportebois/605c81ee3acfa55c1aa047f053a2018e to your computer and use it in GitHub Desktop.
Save sportebois/605c81ee3acfa55c1aa047f053a2018e to your computer and use it in GitHub Desktop.
Read markdown file in the command line
# Markdown utilities (requires `brew install pandoc`)
function mdless () {
local mdfile=$1
if [ -z ${mdfile:+x} ]; then mdfile="README.md"; fi
case $mdfile in
-h | --help)
print "mdless usage: 'mdless myfile.md' or 'mdless' (defaults to README.md)"
;;
*)
mdcat $mdfile | less
;;
esac
}
function mdcat () {
local mdfile=$1
if [ -z ${mdfile:+x} ]; then mdfile="README.md"; fi
pandoc -s -f markdown -t man $mdfile | groff -T utf8 -man
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment