diff options
author | Toby Vincent <tobyv13@gmail.com> | 2023-03-06 18:00:05 -0600 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2023-03-06 18:00:51 -0600 |
commit | 3fd9ed9be5f19e205e5fe619a5874f254254f828 (patch) | |
tree | e437cb1547a950deb33e9511d81a522b5a99e00f /zk | |
parent | 8ea8a5f2d08a258c7eeced382aa921e4a1190896 (diff) |
feat(zk): add script to open zk notes with fzf
Diffstat (limited to 'zk')
-rwxr-xr-x | zk/.local/bin/zkf | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/zk/.local/bin/zkf b/zk/.local/bin/zkf new file mode 100755 index 0000000..5ed7a36 --- /dev/null +++ b/zk/.local/bin/zkf @@ -0,0 +1,22 @@ +#!/bin/sh + +if [ "$#" -eq 0 ]; then + # shellcheck disable=2046 + set -- "$( + rg '#' "$ZK_NOTEBOOK_DIR" --type=markdown --with-filename --max-count=1 --no-line-number | + sed 's/# //' | + fzf-tmux "$FZF_TMUX_OPTS" -- --tac --print-query -d: --with-nth -1 \ + --preview-window='right,80,<80(up,75%,border-bottom)' \ + --preview="bat --color=always --style=plain -l=md -- {1}" | + tail -1 | + cut -d: -f1 + )" +fi + +if [ -z "$1" ]; then + exit 1 +elif [ -f "$1" ]; then + $EDITOR "$1" +else + zk new --title="$1" +fi |