zk: Check WIKIROOT before adding n alias for zk

Since this function also requires a WIKIROOT to be available in the
environment, we should only define it if that variable is not empty --
just like all the other zk aliases and functions.
This commit is contained in:
Marty Oehme 2025-12-10 09:32:14 +01:00
parent 6aa8aefe0e
commit cf544e4740
Signed by: Marty
GPG key ID: 4E535BC19C61886E

View file

@ -1,20 +1,20 @@
#!/usr/bin/env sh
#
_zk_wiki() {
zk --working-dir="$WIKIROOT" "$@"
}
n() {
if [ $# -eq 0 ]; then
_zk_wiki edit -i
else
_zk_wiki "${@}"
fi
}
# We have a local wiki
if [ -n "${WIKIROOT}" ]; then
_zk_wiki() {
zk --working-dir="$WIKIROOT" "$@"
}
n() {
if [ $# -eq 0 ]; then
_zk_wiki edit -i
else
_zk_wiki "${@}"
fi
}
# open notes with my vim zettelkasten plugin
# TODO better implementation conditional on zk.nvim & zettelkasten existing
# nvim +'lua pcall(require "zk.commands"') --headless +qa 2>&1 or similar to check - but slow