Skip to content

Instantly share code, notes, and snippets.

@xealgo
Created February 21, 2020 08:23
Show Gist options
  • Save xealgo/8328cdc5fef8a8ea5481b51f1d874be7 to your computer and use it in GitHub Desktop.
Save xealgo/8328cdc5fef8a8ea5481b51f1d874be7 to your computer and use it in GitHub Desktop.
Watch and render markdown files in the terminal
#!/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
@xealgo
Copy link
Author

xealgo commented Feb 21, 2020

This script is for MacOS and assumes you have homebrew and zsh 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment