Created
March 28, 2017 07:27
-
-
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
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
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