Skip to content

Instantly share code, notes, and snippets.

@lordlabuckdas
Last active May 27, 2021 07:04
Show Gist options
  • Save lordlabuckdas/7674418f86838b7c06c9d2db3b02bdbf to your computer and use it in GitHub Desktop.
Save lordlabuckdas/7674418f86838b7c06c9d2db3b02bdbf to your computer and use it in GitHub Desktop.
a zathura wrapper script for displaying markdown and pdf files using pandoc
#!/bin/bash
# add this to `$HOME/.local/bin` or somewhere in your $PATH
# TODO: implement hash-based caching system to prevent unnecessary pandoc conversion calls
print_usage() {
echo "Zathura wrapper for displaying md and pdf files"
echo -e "Usage:\n\tz FILENAME"
}
if [[ $# == 0 ]]
then
print_usage
exit 1
fi
if [[ ("$1" == "-h") || ("$1" == "--help") ]]
then
print_usage
exit 0
fi
EXT=${1##*.}
if [[ "$EXT" == "pdf" ]]
then
zathura $1
elif [[ "$EXT" == "md" ]]
then
tempFile="/tmp/${1%%.*}.pdf"
pandoc $1 -o $tempFile
zathura $tempFile
else
echo "Only PDF or MD files!"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment