dotfiles/writing/zk/config/sh/alias.d/zk.sh
Marty Oehme 44cd4481a2
zk: Only create aliases if local wiki found
Local wiki requires the '$WIKIROOT' env var to be set, pointing to the
root of the (zk) wiki. So we only create associated aliases if the wiki
actually exists on a machine.
2025-02-22 19:35:38 +01:00

22 lines
575 B
Bash

#!/usr/bin/env sh
#
n() {
if [ $# -eq 0 ]; then
zk edit -i
else
zk "${@}"
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='pushd $WIKIROOT'
fi