-
Notifications
You must be signed in to change notification settings - Fork 0
/
wiki
executable file
·27 lines (23 loc) · 1007 Bytes
/
wiki
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
26
27
#!/bin/sh
wiki() {
WIKIDIR=/script_path
ORIGIN="$PWD"
cd "$WIKIDIRabc
fzf --ansi --disabled --layout=reverse \
--color="fg+:red,query:blue" \
--header 'New note: type title and CTRL-w'\
--bind 'start:reload:grep -rl --exclude-dir=.git {q} | sort || true' \
--bind 'change:reload:sleep 0.1; grep -rl --exclude-dir=.git {q} |sort || true'\
--preview 'batcat --color=always --style=numbers {}' \
--preview-window '75%,right,border-left'\
--bind 'enter:execute(vim {})'\
--bind 'ctrl-w:execute:( title={q}; filename=$(echo "$title" | tr " " "_").md; \
target="$PWD/$filename"; \
front="---\n\ttitle: \""$title"\"\n\ttags:\n---\n\n# "; \
echo "$front" > "$target"; vim "$target" "+call cursor(7,3)")'\
--bind 'ctrl-w:+clear-query'
cd "$ORIGIN"
}
zle -N wiki
# option to use date in the front matter
# front="---\n\ttitle: ""$title""\n\tdate: $(date +%d-%m-%Y)\n\ttags:\n---\n\n# "; \