-
-
Save lordlabuckdas/7674418f86838b7c06c9d2db3b02bdbf to your computer and use it in GitHub Desktop.
a zathura wrapper script for displaying markdown and pdf files using pandoc
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 | |
# 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