Back when I didn't mind using GUIs, I was pretty impressed by what I read about Notational Velocity. I never owned a Mac so after some searching around I found nvpy, a nice cross-platform tool that tries to resemble its functionality. Alas - apart from the initial toying around - I never used it. The reason, as most of the time, was that it added friction to my workflow. You have to open it explicitly and do your edits inside the application. No modes, no vim keybindings and which virtual desktop was it on again?
A few days ago I came across this blog post and this lifehacker article that seemed like a good starting point to get some of the functionality without any friction.
I decided to use .md
instead of .txt
as a file suffix because I want to get
used to writing markdown to take advantage of pandoc and my
notes directory is ~/.notes
instead of ~/notes
so it won't clutter the
output of ls
in my home directory.
My nls()
function is a little different from what is shown in the articles though:
nls() {
tree -CR --noreport ~/.notes | sed 's/.md$//' | awk '{$1=""; print}' \
| grep -i "$*"
}
This takes care of:
- removing the trailing .md (the 'sed ...' part)
- removing the leading characters of the tree output (the 'awk...' part)
The grep
should be self-explanatory. If it isn't, there's always man grep
.
This way I can use the output of this function as input for the n()
function.
There was one more itch to scratch, though:
You can search for your note's titles but you can't do a full text search on all your notes, so if you don't remember which file contains the desired information, you're screwed.
Enter the Silver Searcher
There's a nice utility called The
Silver Searcher that works as a
grep replacement. With the -l
option, it just prints the names of the files
containing your search phrase. So in addition to the two functions mentioned in
the above articles I wrote this small function:
nsearch() {
cd ~/.notes/
ag -l "$*" | sed 's/.md$//'
cd - > /dev/null
}
Now, with
$ nsearch <my_phrase>
I get a list of all files in ~/.notes/
containing <my_phrase>
. As above, the
.md
extension is removed from the output for use with the n()
function.
I still have to take care about syncing my notes between machines, but it works for now.