4 ms·
I have my notes in Dendron which is basically a directory of yaml files. I often need to search through the notes so I made the below search_notes() { input=
by muskmusk 4y ago
I have my notes in Dendron which is basically a directory of yaml files. I often need to search through the notes so I made the below
search_notes() {
input=$(rg -v '(\-\-)|(^\s*$)' --line-number /home/user/some-dir | fzf --ansi --delimiter : --preview 'batcat --color=always {1} --highlight-line {2}' --preview-window 'up,60%,border-bottom,+{2}+3/3,~3' | choose -f : 0)
if [[$input = ""]]; then
else
less $input
fi
}
It uses various linux utilities including fzf and batcat(https://github.com/sharkdp/bat https://github.com/sharkdp/bat) to open a terminal with all the places where my query comes up (supporting fuzzy search). Since the workhorses are fzf and ripgrep its is quite fast even for very large directories.
So i will do `search_notes postgres authentication`. I can select a line and it will open the file in less. Works like a charm!