Skip to content

Instantly share code, notes, and snippets.

@ff6347
Created March 28, 2017 07:27
Show Gist options
  • Save ff6347/78ce60549fcca4c0e3fe4e6dc06bf576 to your computer and use it in GitHub Desktop.
Save ff6347/78ce60549fcca4c0e3fe4e6dc06bf576 to your computer and use it in GitHub Desktop.
a little tool for previewing markdown in the command line for fish shell save it under ~/.config/fish/functions/mdview.fish
function mdview
if set -q argv
switch $argv
case -h
echo "[M↓] Help"
echo "call the mdview with a Markdown [M↓] file as argument"
echo "this script needs pandoc and lynx installed"
echo "on macOS run 'brew install pandoc lynx'"
case "*"
# check if pandoc is installed
if pandoc -v >/dev/null do
# check if lynx is installed
if lynx -version >/dev/null do
# run the magic
pass the file to pandoc
it will be converted to HTML and go to stdout
pipe it into lynx stdin
pandoc $argv | lynx -stdin
else
echo "lynx is not installed"
end
else
echo "pandoc is not installed"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment