Bashing out notes

There are several pieces of software I yearn for, and occasionally go on wild goose chases across the Interwebs looking for. A note-taking application that fits my brain is one. My criteria aren't exactly demanding; in fact, they boil down to two needs and two desires.

Need 1: It must appear and disappear immediately.

I don't have the screen real estate for little knick-knacks like side-docks or drop windows, et cetera, and I don't have the patience to go hunting them when I need them. Nor do I have the patience for a complex GUI. I either want to take a note, or read a note, and I want to do it while the slippery little gremlin of inspiration is still trapped in the fragile jaws of my brain.

Need 2: Powerful search.

I'm not going to go tagging or coloring my notes. I'm not going to drop them into a neat folder hierarchy. I mean I'd love to, but I know from experience that it's just not going to happen. So let me have a big stinking haystack of notes, and use search to find my needles.

Great search lets me use the application as a scratchpad, dumping ideas and discoveries down and getting back to work. I know I'll find them later.

Desire 1: Let me repurpose my data.

I take a lot of notes, and over the years my jottings accidentally became a treasure trove (another man's trash, etc). So I don't want them in an opaque or proprietary database. I want to be able to move them around between various machines, archive them from the command-line, sync them with my iPhod, write a script to build a wiki out of them, whatever.

Desire 2: It should work the way my text editor works.

I'm switching between my text editor and various terminals 12 hours a day. My text editor is vim, which works rather differently to most GUI-based text entry widgets. I'd like to be able to enter and edit my notes like I do my code.

A bashful solution

On Ubuntu, Tomboy satisfied my two needs. It was simple and delightful. When I moved to Mac OS X, I searched high and low for a replacement, and eventually found the charmingly quirky Notational Velocity. It also satisfied my two needs, sort of. I had it bound to F4 in Quicksilver, so it was easy to invoke, and I could just Cmd-Q to dismiss it. But startup became very sluggish after I'd accumulated several hundred notes, and inevitably my patience ran out.

So this time, I researched just enough bash to be dangerous, and wrote a short script to do what I needed and what I desired. Here it is in full:

note() {
  if [ -n "$*" ]; then
    vim "$HOME/.notes/$*.note"
    printf "Name of note is a required argument.\n"

findnote() {
  ack -ia $1 ~/.notes

copynote() {
  cat "$HOME/.notes/$*.note" | pbcopy

alias note:='note'
alias notes='vim $HOME/.notes'

_notes() {
  local cur names IFS

  names=`ls $HOME/.notes | sed 's/.note$//g'`

  COMPREPLY=( $(compgen -W "${names}" -- ${cur}) )
  return 0
complete -o nospace -F _notes note
complete -o nospace -F _notes note:

Put that in a file (mine is in ~/scripts/bash_notes) and source it (ie source ~/scripts/bash_notes). Then mkdir ~/.notes.

That's it. Now you've got a few tools at your command-line disposal:

note Guitar tabs

Will create or open ~/.notes/Guitar tabs.note in vim. It's aliased to 'note:' too, so you can use note: Guitar tabs if you prefer.


Opens your notes directory in vim, allowing you to browse, rename, delete at will.

findnote thurston

Shows excerpts from every note in which the string 'thurston' is found. This is just a simple wrapper around ack, the wonderful grep-alike. You'll need to have that in your path somewhere (/usr/local/bin being the logical place in Mac OS X).

copynote Guitar tabs

Copies the contents of the 'Guitar tabs' note to your clipboard on Mac OS X.

But the exciting bit is the custom tab-completion. Type note and hit Tab to list all your notes. Type note Gui and hit Tab to complete the "Guitar tabs" title at the command line. Fast!

If you're not yet won over to the way of vim, you can use this script with TextMate too — just replace all the references to vim with mate.

Try Visor if you want to keep your notes a keypress away. Remember to source the bash_notes script in your .profile so it's available in all your Terminal sessions. And let me know if it fits your brain too.

Joseph | 8 Jan 2008

Wed 9 Jan 2008, 12:42AM Daniel Aleksandersen

Maybe you should try and write this as an application with a propper database back‐end, Joseph? That way, I think it would be much more scalable; and do search much faster [once it scales].

PostgreSQL—or some other SQL flavor—seams to be the right choice for you here.

Wed 9 Jan 2008, 8:28AM Joseph

I'm afraid I can't tell if you're joking. This system scales to many thousands of notes. It has no concurrency requirements. Using text files means speaking the lingua franca of text editors, scripting languages and hundreds of useful command-line utilities. You could with a single command version-control all your notes with git or Subversion, for instance. I'd be mad to trade all that in just because there's a current fetish for database solutions, or for an undetectable split-second optimization to search results. (And, indeed, if I was that mad, I'd be looking at CouchDb or ThruDB or even SimpleDB before Postgres. But more to the point: I ain't that crazy.)

Tue 1 Apr 2008, 4:47AM Adrian Rollett

awesome hint - I went ahead and added

complete -o nospace -F _notes copynote

to the end of the file. Also added the following to open all files matching the search string in tabs with the excellent MacVim.

opennote() {
  ack -il $1 ~/.notes/* | sed s/\ /\\\ /g|xargs ~/bin/mvim -p

Tue 1 Apr 2008, 5:00AM Adrian Rollett

hrrmm, slightly more elegant version of the above would be:

ack -il --print0 $1 ~/.notes/* | xargs -0 ~/bin/mvim -p

Wed 2 Apr 2008, 2:07PM Adrian Rollett

Ok, my last comment over here, I promise ;) I posted about adding tags to this system at

Thu 13 Nov 2008, 11:40PM Vasily Mikhailitchenko

Wow, this is really neat! Thank you Joseph. Started using it.

Fri 5 Dec 2008, 3:11PM joe

this is dope, thanks so much for posting. and putting all your notes in ~/.notes is a good idea too!

Tue 10 Nov 2009, 4:57AM Blippy

Sounds like you were emulating the PPC version of Notational Velocity from 2003. Might want to keep up to date and get the universal binary version.

Sorry, comments are not available on this post.

stuff & nonsense

  • Topographic viewTopographic view
     shows elements on a webpage according to how deeply nested they are. It's a bookmarklet for web development.
  • The qualifierThe qualifier
     renders controversial statements on this page harmless. Reinstate the slings and barbs by refreshing. Also a bookmarklet.

  • jjmap
    American Diary

    Two weeks with the apple and the lone star (illustrated).

all posts, ordered by month in reverse-chronological order:

In Words

In Other Words