-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdtopdf.sh
executable file
·13 lines (10 loc) · 792 Bytes
/
mdtopdf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
# A basic script to convert md to pdf using pandoc and open it if given the argument(Made to be used with vim)
# Argument 1 is the name and location of the file, Arg. 2 is the flag to open it or not. Just supply "open" as second arg. to open.
x=$(echo "$HOME" | sed "s/\//\\\\\//g")
INPUT=$1
OUTPUT=$(echo "$1" | awk -F"." '{print $1}')
OUTPUT="${OUTPUT##*\/}"
# sed "s/\$HOME/$x/g" "$INPUT" | pandoc -V geometry:paperwidth=4in -V geometry:paperheight=9in -i -o "$HOME"/vimwiki/pdf/"$OUTPUT".pdf # For phones
sed "s/\$HOME/$x/g" "$INPUT" | pandoc -V geometry:left=4cm -V geometry:right=4cm -V geometry:top=5mm -V geometry:bottom=5mm -V geometry:paperheight=10in -i -o "$HOME"/vimwiki/pdf/"$OUTPUT".pdf
([ "$2" = "open" ] && zathura "$HOME"/vimwiki/pdf/"$OUTPUT".pdf) || exit 0