Created
February 10, 2018 18:38
-
-
Save sportebois/605c81ee3acfa55c1aa047f053a2018e to your computer and use it in GitHub Desktop.
Read markdown file in the command line
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
# 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