Skip to content

Instantly share code, notes, and snippets.

@p410n3
Last active September 12, 2019 12:24
Show Gist options
  • Save p410n3/8b81590035a682b2b173020aa42dc824 to your computer and use it in GitHub Desktop.
Save p410n3/8b81590035a682b2b173020aa42dc824 to your computer and use it in GitHub Desktop.
Small script that uses pandoc and dmenu to comfortably convert .md to .pdf
#!/bin/bash
# First arg is the folder
_folder=$1
# If _folder is empty, use pwd as default
if [[ -z $_folder ]]; then
_folder=`pwd`;
fi
# Open the dmenu with all md files
_filename=`ls $_folder | grep '^.*\.md$' | dmenu -l 10`
# When dmenu is aborted, it will be empty, exit in that case
if [[ -z $_filename ]]; then
echo 'Aborted from dmenu'
exit 0;
fi
# Now convert it to pdf and drop in .
pandoc $_folder$_filename -o "${_filename}.pdf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment