summaryrefslogtreecommitdiff
path: root/scripts/.local/bin/compiler
blob: 25c0a3c5fc26c93f691aaae9aaa80d2c8143fb94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh

# Setting Vars
FILE=$(basename "$1")
EXTENSION=$(echo "$FILE" | awk -F . '{if (NF>1) {print $NF}}')
BASE=$(basename "$FILE" ."$EXTENSION")

# Filter to compile other types of files
if [ "$#" -eq 2 ] && { [ -e "$2/Makefile" ] || [ -e "$2/makefile" ]; }; then
	make
else
	case $EXTENSION in
	c|h)
		cc -o "$BASE" ./*.c
		;;
	cpp)
		c++ -o "$BASE" ./*.cpp
		;;
	java)
		javac "$FILE" ./*.java
		;;
	md|rmd)
		FORMAT=$(printf "PDF\nHTML\nBeamer\nODT\nDOCX\nPPTX\n" | dmenu -i -p "Format:")
		case "$FORMAT" in
			PDF)
				pandoc "$FILE" --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash \
					--output "$BASE".pdf --self-contained --highlight-style tango --pdf-engine xelatex \
					--variable graphics --variable 'geometry:margin=1in' -V 'mathfont:Symbola'
				;;
			HTML)
				pandoc "$FILE" --to html --output "$BASE".html
				;;
			Beamer)
				pandoc "$FILE" --to beamer --from markdown+autolink_bare_uris+tex_math_single_backslash --output "$BASE".pdf \
					--highlight-style tango --pdf-engine pdflatex --self-contained
				;;
			ODT)
				pandoc "$FILE" --to odt --from markdown+autolink_bare_uris+tex_math_single_backslash --output "$BASE".odt
				;;
			DOCX)
				pandoc "$FILE" --to docx --from markdown+autolink_bare_uris+tex_math_single_backslash --output "$BASE".docx \
					--highlight-style tango
				;;
			PPTX)
				pandoc "$FILE" --to pptx --from markdown+autolink_bare_uris+tex_math_single_backslash --output "$BASE".pptx
		esac
		;;
	ms)
		groff -k -T pdf -m -ms "$FILE" > "$BASE.pdf"
		;;
	js)
		node "$FILE"
		;;
	tex)
		pdflatex "$FILE"
	esac
fi