-
Notifications
You must be signed in to change notification settings - Fork 1
/
zs
executable file
·25 lines (22 loc) · 1.06 KB
/
zs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
#
# zs - is a zettel selector using fzf
# features:
# - it accepts multiple selection (using tab)
# - copy multiple selection to clipboard (mapped to ctrl-y)
# - clear selection (mapped to ctrl-l)
# - populates (n)vim quickfix list with zettel titles (enter)
#
SRC_FOLDER=$HOME/notes/
main() {
cd "$SRC_FOLDER"
grep --max-count=1 --with-filename "^#[[:space:]][[:alnum:]]" *.md | sed 's/:#[[:space:]]/ | /g' | fzf --tac --multi \
--layout=reverse \
--preview "echo {} | sed 's/[[:space:]].*//g' | head | xargs batcat --style=plain --color=always" \
--preview-window=wrap \
--bind '?:toggle-preview' \
--bind 'ctrl-l:clear-selection' \
--bind "ctrl-y:execute(printf '%s\n' {+} | xclip -selection clipboard)" \
--bind 'enter:execute(echo {+} | grep -o "[0-9]\+\.md" | xargs -o $EDITOR -c "silent bufdo grepadd ^\# %")'
}
main