refactor(zk): clean up and simplify zk module
check / lint (push) Successful in 15s

This commit is contained in:
2026-08-23 13:56:53 +02:00
parent 3c97d0a21f
commit 028a6611d2
5 changed files with 19 additions and 38 deletions
-4
View File
@@ -61,10 +61,6 @@ export JUPYTERLAB_DIR=$HOME/.local/share/jupyter/lab
[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && . /opt/miniconda3/etc/profile.d/conda.sh [ -f /opt/miniconda3/etc/profile.d/conda.sh ] && . /opt/miniconda3/etc/profile.d/conda.sh
# }}} # }}}
# Zettelkasten {{{
export ZK_PATH="$HOME/.zk"
# Codi # Codi
# Usage: codi [filetype] [filename] # Usage: codi [filetype] [filename]
codi() { codi() {
+6 -15
View File
@@ -13,8 +13,7 @@ in
enable = lib.mkEnableOption "zettelkasten"; enable = lib.mkEnableOption "zettelkasten";
path = lib.mkOption { path = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = config.home.homeDirectory + "/.zk"; default = "${config.home.homeDirectory}/.zk";
description = "Path to the zettelkasten directory";
}; };
}; };
@@ -24,21 +23,13 @@ in
packages = [ packages = [
(pkgs.writeShellApplication { (pkgs.writeShellApplication {
name = "zk"; name = "zk";
runtimeInputs = with pkgs; [ tmux ]; runtimeInputs = with pkgs; [
tmux
gh
];
runtimeEnv.ZK_PATH = cfg.path;
text = builtins.readFile ./scripts/zk.sh; text = builtins.readFile ./scripts/zk.sh;
}) })
(pkgs.writeShellApplication {
name = "save-zk";
runtimeInputs = with pkgs; [ git ];
text = builtins.readFile ./scripts/save-zk.sh;
})
(pkgs.writeShellApplication {
name = "setup-zk";
runtimeInputs = with pkgs; [ gh ];
text = builtins.readFile ./scripts/setup-zk.sh;
})
]; ];
}; };
}; };
-2
View File
@@ -1,2 +0,0 @@
cd "$ZK_PATH" || { echo "No zettelkasten directory found"; exit 1; }
git add . && git commit -m "Update" && git push
-13
View File
@@ -1,13 +0,0 @@
if [ ! -d "$ZK_PATH" ]; then
echo "[zk] Setting up zettelkasten"
gh repo clone zk "$ZK_PATH"
else
echo "[zk] Zettelkasten already set up."
fi
read -p "Would you like open your zettelkasten? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
$EDITOR "$ZK_PATH"
fi
+13 -4
View File
@@ -1,7 +1,16 @@
current_zettel_path="$(cat "$ZK_PATH/current-zettel.txt")" if [ ! -d "$ZK_PATH" ]; then
echo "[zk] Setting up zettelkasten"
gh repo clone zk "$ZK_PATH"
fi
if [ -f "$ZK_PATH/current-zettel.txt" ]; then
target="$(cat "$ZK_PATH/current-zettel.txt")"
else
target="."
fi
if [ -n "${TMUX:-}" ]; then if [ -n "${TMUX:-}" ]; then
cd "$ZK_PATH" && $EDITOR "$current_zettel_path" cd "$ZK_PATH" && $EDITOR "$target"
else else
echo 'Not in tmux' echo 'Not in tmux'
echo 'Choose an option:' echo 'Choose an option:'
@@ -14,12 +23,12 @@ else
tmux attach -t zk tmux attach -t zk
else else
tmux new-session -s zk -n zk -d tmux new-session -s zk -n zk -d
tmux send-keys -t zk:zk "cd $ZK_PATH && $EDITOR $current_zettel_path" Enter tmux send-keys -t zk:zk "cd ${ZK_PATH} && $EDITOR ${target}" Enter
tmux attach -t zk tmux attach -t zk
fi fi
;; ;;
2) 2)
cd "$ZK_PATH" && $EDITOR "$current_zettel_path" cd "$ZK_PATH" && $EDITOR "$target"
;; ;;
*) *)
echo 'Not opening Zettelkasten' echo 'Not opening Zettelkasten'