From f62839bc3bf8944602e963419650566f1ca81996 Mon Sep 17 00:00:00 2001 From: sheldonmlee Date: Fri, 22 Oct 2021 00:13:22 +0800 Subject: [PATCH] Add script to generate pdfs from MD using pandoc. viewmd() now openes said generated pdf file if it exists. --- .custom_bash_scripts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.custom_bash_scripts b/.custom_bash_scripts index 2c81b3f..ab7f909 100644 --- a/.custom_bash_scripts +++ b/.custom_bash_scripts @@ -78,6 +78,21 @@ viewmd() { [ -z $1 ] && return [ ! -f $1 ] && return - pandoc -t pdf $1 | zathura - & disown + pdfname=$(basename $1 .md).pdf + echo $pdfname + if [ -f $pdfname ]; then + zathura $pdfname & disown + else + pandoc -t pdf $1 | zathura - & disown + fi } +# generate markdown files from markdown +makemd() +{ + [ -z $1 ] && return + [ ! -f $1 ] && return + pandoc -t pdf $1 -o $(basename $1 .md).pdf +} + +