-
-
Save mslinn/3c6cb4445e8b3efcac147961d2dd9602 to your computer and use it in GitHub Desktop.
View GitHub Markdown files in a console
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
#!/bin/bash | |
function help { | |
echo "View GitHub markdown files in a console using less. | |
1. Install pandoc and lynx. | |
a. For Ubuntu (and WSL): sudo apt install pandoc lynx | |
b. For MacOS: brew install pandoc lynx | |
2. Name the this script as less and save it somewhere on the PATH, for example /usr/local/bin. | |
3. Make the script executable, for example: chmod a+x /usr/local/bin/less. | |
4. Type 'hash -r' or /usr/bin/less will run instead of this script | |
5. Type 'less myfile.md' to view a file as usual; this script will handle files with filetype md as GitHub markdown and render colorized output to the console | |
" | |
exit 1 | |
} | |
if [ "$1" == -h ]; then help; fi | |
if [ "${1##*.}" == md ]; then | |
pandoc "$1" | lynx -stdin | |
else | |
/usr/bin/less "$1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment