Trunk Notes lookups from the desktop

Trunk Notes Overview

One of the most use­ful apps I have dis­cov­ered for the iPhone is called Trunk Notes.  Effectively, it is a “wiki” or series of inter­linked notes, that you can carry around in your pocket.  I actu­ally don’t use it so much for the inter­link­ing — tag­ging and search are plenty enough for me — but this app really shines in two fea­tures that are cer­tainly not avail­able in the built-in Notes app and which are a bit rare on other apps.

The first of these two fea­tures is WiFi shar­ing.  When you enable this, it turns your phone into a lit­tle web­server that you can get to from your desk­top browser.  This makes cut­ting, past­ing, and larger struc­tural edits super-easy because you have a full screen and full key­board.  You are not con­strained by the lim­its of the iPhone’s screen and key­board or the mul­ti­ple ges­tures required to copy and paste text.

The other key fea­ture is Dropbox syn­chro­niza­tion.  As much as I respect­fully dis­agree with some of Dropbox’s recent moves (to the point of mov­ing all but iPhone-synced data to SpiderOak), I have to admit that syn­chro­niza­tion between com­put­ers and phones via Dropbox is noth­ing short of mag­i­cal.

Trunk Notes syn­chro­nizes its con­tents to Dropbox as a col­lec­tion of text files.  I can then search and edit those on my desk­top.  Mainly I search, since it’s eas­ier to edit on the phone or via the WiFi shar­ing.  I got a lit­tle bit tired of con­stantly run­ning “grep” in my trunk­sync folder then “less” on the result, so I wrap­pered it in a shell script.

Notes” Script Overview

The script itself is called “notes” and lets you place a search term on the com­mand line.  I can enter “notes apple” and it responds with a list of all notes men­tion­ing the term “apple” (in upper or low­er­case).

Given this list, I can then select one and bring up the con­tent of the note with my search term high­lighted.


The “notes” script is a Bash shell script.  This means it will run on Unix or any Unix-like oper­at­ing sys­tem.  These include the stock Linux and OS X installs.  It can also be run on Windows under the Cygwin com­mand shell.  (The details of installing and con­fig­ur­ing Cygwin are beyond the scope of this post.  They have some mighty fine doc­u­men­ta­tion.)  To install, you just need to cre­ate the script, mark it as exe­cutable (chmod 755), and put it some­where in your path (/usr/local/bin).  If your Dropbox folder is in a dif­fer­ent place than your home direc­tory or if you’re sync­ing with a Trunk Notes folder other than trunk­sync, then you’ll have to make the appro­pri­ate mod­i­fi­ca­tions.


The script is as fol­lows:

if [ -z "$1" ]; then
    echo "Put search term on command line"
    exit 1

# Set this to:
#  0 to only show matching notes
#  1 to show matches lines in context first, before printing matching notes

# Find matches
grep -r -i -l "$1" ~/Dropbox/trunksync/notes > $LIST
if [ $PRINT_MATCHES_IN_CONTEXT -eq 1 ]; then
    grep -r -i --color "$1" ~/Dropbox/trunksync/notes
    echo ""

# Display list of matching files
echo "[0] abort"
while read LINE
    FILE=`basename "$LINE"`
    echo "[$COUNTER] $FILE"

# Ask for selection
echo -n "Selection: "

# Find file that matches selection and display it
while read LINE
    if [ "$COUNTER" == "$SELECTION" ]; then
        less -i -p "$1" "$LINE"

# Clean up temp file
rm -f $LIST
Posted in: Code iPhone

Published by

Brian Enigma

Brian Enigma is a Portlander, manipulator of atoms & bits, minor-league blogger, and all-around great guy. He typically writes about the interesting “maker” projects he's working on, but sometimes veers off into puzzles, software, games, local news, and current events.

One thought on “Trunk Notes lookups from the desktop”

Leave a Reply

Your email address will not be published. Required fields are marked *