dotfiles/writing/zk/config/sh/alias.d/zk.sh
Marty Oehme 613df98520
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").
2025-02-22 19:35:38 +01:00

34 lines
730 B
Bash

#!/usr/bin/env sh
#
_zk_wiki() {
zk --notebook-dir="$WIKIROOT" "$@"
}
n() {
if [ $# -eq 0 ]; then
_zk_wiki edit -i
else
_zk_wiki "${@}"
fi
}
# We have a local wiki
if [ -n "${WIKIROOT}" ]; then
# 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
if command -v nvim >/dev/null 2>&1; then
alias ni='nvim +"lua require \"zk.commands\".get(\"ZkCd\")()" +"edit $WIKIROOT/index.md"'
fi
alias ncd='cd $WIKIROOT'
nnd() {
_zk_wiki draft "$@"
}
nn() {
_zk_wiki new "$@"
}
fi