-
-
Save benevidesh/d78f7681120a13d5386ea55b39d82c9b to your computer and use it in GitHub Desktop.
#!/usr/bin/bash | |
# zn - as zettell | |
# new export variables EDITOR for your editor and | |
#+ NOTES for your notes folder. | |
main () { | |
note_id=$(date +'%Y%m%d%H%M%S') | |
$EDITOR $NOTES/"$note_id".md | |
} | |
main |
#!/usr/bin/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=$(pwd) | |
main() { | |
cd "$SRC_FOLDER" | |
grep --max-count=1 "^#[[:space:]][[:alnum:]]" *.md | sed 's/:#[[:space:]]/ | /g' | fzf --tac --multi \ | |
--layout=reverse \ | |
--preview "echo {} | sed 's/[[:space:]].*//g' | head | xargs bat --style=plain --color=always || xargs cat {}" \ | |
--preview-window=wrap \ | |
--bind '?:toggle-preview' \ | |
--bind 'ctrl-l:clear-selection' \ | |
--bind "ctrl-y:execute(printf '%s\n' {+} | sed 's/.md//g' | xclip -selection clipboard)" \ | |
--bind 'enter:execute(echo {+} | grep -o "[0-9]\+\.md" | xargs $EDITOR -c "silent bufdo grepadd ^\# %")' | |
} | |
main | |
Would very much love to use this --- but when calling zn
I get the error:
> zn main:2: no such file or directory: /Users/udax/zettel/20221020160540.md
My zn
file appears thus:
#!/bin/zsh
main () {
note_id=$(date +'%Y%m%d%H%M%S')
$EDITOR $NOTES/"$note_id".md
}
main
My zs
file:
#!/bin/zsh
main() {
cd "$NOTES"
grep --max-count=1 "^#[[:space:]][[:alnum:]]" *.md | sed 's/:#[[:space:]]/ | /g' | fzf --tac --multi \
--layout=reverse \
--preview "echo {} | sed 's/[[:space:]].*//g' | head | xargs bat --style=plain --color=always || xargs cat {}" \
--preview-window=wrap \
--bind '?:toggle-preview' \
--bind 'ctrl-l:clear-selection' \
--bind "ctrl-y:execute(printf '%s\n' {+} | sed 's/.md//g' | pbcopy)" \
--bind 'enter:execute(echo {+} | grep -o "[0-9]\+\.md" | xargs $EDITOR -c "silent bufdo grepadd ^\# %")'
}
main
NOTE - I replaced xclip
command with pbcopy
in the hopes that somehow that was the hold up.
For what it's worth, I am on a Mac 12.6
Any thoughts would be appreciated!
Would very much love to use this --- but when calling
zn
I get the error:> zn main:2: no such file or directory: /Users/udax/zettel/20221020160540.md
My
zn
file appears thus: ` #!/bin/zsh main () { note_id=$(date +'%Y%m%d%H%M%S') $EDITOR $NOTES/"$note_id".md }main ` For what it's worth, I am on a Mac 12.6 Any thoughts would be appreciated!
It looks like the $NOTES variable is not set either in the script or your shell as an environment variable.
What does echo $NOTES
output in your terminal?
It has been set:
echo $NOTES
/Users/udax/zettel
My .zshrc
file contains:
export NOTES="/Users/udax/zettel"
Well, as is true with almost all of my requests for help, I am embarrassed to say that it was rather obvious:
The EDITOR variable was not set. I simply set it:
export EDITOR=vim
and, as night follows day, it worked.
Sorry.
As an afterthought --- perhaps I'm wrong but I didn't see any discussion of that env variable. (Again, perhaps I am wrong. It has happened on occasion.)
Thanks!
Hey guys!
New scripts: https://github.com/benevidesh/zettelmaking
What is new? A script named zex
(for zettelExplorer) that makes interactive real time queries trough your notes. Check it out!
Hi! Thank you for sharing these scripts, they are powerful and minimalistic.
I've dockerized your scripts to freeze nvim/tmux configs and to implement automatic git syncronization: https://github.com/m-danya/dockerized-zk. Maybe one day I will hybreed your fzf-based approach with vimwiki
plugin, which have nifty links displaying.
Hey @buggysolid,
Thanks for spreading the word of Zettelkasten Minimalism. 😅️