-
-
Save xealgo/8328cdc5fef8a8ea5481b51f1d874be7 to your computer and use it in GitHub Desktop.
Watch and render markdown files in the terminal
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/zsh | |
if [ -z "$1" ]; then | |
echo No filename specified; | |
exit; | |
fi | |
if ! fswatch_loc="$(type -p 'fswatch')" || [[ -z $fswatch_loc ]]; then | |
brew install fswatch | |
fi | |
if ! mdcat_loc="$(type -p 'mdcat')" || [[ -z $mdcat_loc ]]; then | |
brew install mdcat | |
fi | |
echo watching $1.... | |
while true; | |
do | |
clear; | |
mdcat $1; | |
fswatch -1 $1; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script is for MacOS and assumes you have
homebrew
andzsh
installed. It could be modified to use bash and whatever package manager you're using on Linux. I'm not a shell script expert, so feel free to point out improvements / issues. Pro tip: using iTerm (or Tmux) create a vertical split for live preview.