From edafaf3c144cb36ba5ea8e49846218ad0d5a2522 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Sun, 5 Jan 2025 03:19:20 +0100 Subject: [PATCH] improve `typed` command --- modules/shell/nu/custom_commands.nu | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/shell/nu/custom_commands.nu b/modules/shell/nu/custom_commands.nu index e3581f3..5b66b1b 100644 --- a/modules/shell/nu/custom_commands.nu +++ b/modules/shell/nu/custom_commands.nu @@ -38,8 +38,13 @@ def glog [ def typed [ name: string ] { - touch $"($name).typ" - typst compile $"($name).typ" + const DEFAULT_TYPST_FILE = "#import \"@local/typst-configs:0.1.0\": generic, sf;\n#show: generic.with();" + if not ($"($name).typ" | path exists) and not ($"($name).pdf" | path exists) { + $DEFAULT_TYPST_FILE | save $"($name).typ" + typst compile $"($name).typ" + } else if ($"($name).pdf" | path exists) { + typst compile $"($name).typ" + } mprocs --names Editor,Viewer,Notify $"hx '($name).typ'" $"while true; do mupdf-x11 '($name).pdf' && break; done" $"while inotifywait -e modify '($name).pdf' ; do pkill -HUP mupdf; done" }