From bbb66dc0a2aadec8c5a5ef983bd3fe69e150a78d Mon Sep 17 00:00:00 2001 From: probablygecko Date: Fri, 11 Jul 2025 23:10:37 +0200 Subject: [PATCH] first push, simple Typst Helper --- typ | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 typ diff --git a/typ b/typ new file mode 100755 index 0000000..b916ad0 --- /dev/null +++ b/typ @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +import os +import subprocess +import sys +import time +from datetime import datetime + +if len(sys.argv) < 2: + print("Usage: typ ") + sys.exit(1) + +base = sys.argv[1].strip() + +date_str = datetime.now().strftime("%Y%m%d") + +filename = f"{base}_{date_str}.typ" + +if not os.path.isfile(filename): + print(f"File '{filename}' does not exist.") + with open(filename, 'w') as f: + f.write("") + +with open(os.devnull, "wb") as devnull: + subprocess.Popen(['code', filename], stdout=devnull, stderr=devnull) + +typst_proc = subprocess.Popen(['typst', 'watch', filename]) + +pdf_file = f"{base}_{date_str}.pdf" + +if not os.path.isfile(pdf_file): + for _ in range(10): + if os.path.isfile(pdf_file): + break + time.sleep(1) + +if os.path.isfile(pdf_file): + with open(os.devnull, "wb") as devnull: + subprocess.Popen(['evince', pdf_file], stdout=devnull, stderr=devnull) +else: + pass +typst_proc.wait()