From 613df985205a50d6cf8fc3f98783c4c6a7b88094 Mon Sep 17 00:00:00 2001
From: Marty Oehme <marty.oehme@gmail.com>
Date: Sat, 22 Feb 2025 13:28:30 +0100
Subject: [PATCH] zk: Ensure global wiki cmds are always executed in wiki

We use a custom zk indirection which ensures that any short alias for
interacting with the zk wiki will actually act on the globally assigned
wiki (by ensuring notebooks dir is "$WIKIROOT").
---
 writing/zk/config/sh/alias.d/zk.sh | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/writing/zk/config/sh/alias.d/zk.sh b/writing/zk/config/sh/alias.d/zk.sh
index fc7d73a..dc506dd 100644
--- a/writing/zk/config/sh/alias.d/zk.sh
+++ b/writing/zk/config/sh/alias.d/zk.sh
@@ -1,14 +1,20 @@
 #!/usr/bin/env sh
 #
 
+_zk_wiki() {
+    zk --notebook-dir="$WIKIROOT" "$@"
+}
+
 n() {
     if [ $# -eq 0 ]; then
-        zk edit -i
+        _zk_wiki edit -i
     else
-        zk "${@}"
+        _zk_wiki "${@}"
     fi
 }
 
+
+
 # We have a local wiki
 if [ -n "${WIKIROOT}" ]; then
     # open notes with my vim zettelkasten plugin
@@ -18,5 +24,11 @@ if [ -n "${WIKIROOT}" ]; then
         alias ni='nvim +"lua require \"zk.commands\".get(\"ZkCd\")()" +"edit $WIKIROOT/index.md"'
     fi
 
-    alias ncd='pushd $WIKIROOT'
+    alias ncd='cd $WIKIROOT'
+    nnd() {
+        _zk_wiki draft "$@"
+    }
+    nn() {
+        _zk_wiki new "$@"
+    }
 fi