summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/zet33
1 files changed, 33 insertions, 0 deletions
diff --git a/bin/zet b/bin/zet
new file mode 100755
index 0000000..7e98bd9
--- /dev/null
+++ b/bin/zet
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+ZET_DIR=$HOME/wiki
+
+case "$1" in
+    ls) 
+        if [ -z "$2" ]; then
+            fd -t f -e md '.*' "${ZET_DIR}"
+        else
+            shift 1
+            rg --no-ignore --files-with-matches "$@" "${ZET_DIR}" \
+                | fzf --preview="cat -n {} | grep --color=always -C 3 '$@'" --bind 'enter:execute(nvim {})'
+        fi
+        ;;
+
+    new)
+        f="${ZET_DIR}/$(date +%Y)/$2"
+        if [ -z "$f" ]; then
+            f="$(fzf --prompt="filename?> " --print-query)"
+        fi
+        if [ ! -f "$f" ]; then
+            {
+                echo "---";
+                yq n date "$(date -Iseconds)";
+                echo "---";
+                echo "";
+            } >> "$f"
+        fi
+        nvim "$f"
+        ;;
+
+    *) nvim "+Zet $*" ;;
+esac