Skip to content

Instantly share code, notes, and snippets.

@yig
Created January 28, 2017 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yig/76e87324ca1e9c754e8f28a8ef294dd0 to your computer and use it in GitHub Desktop.
Save yig/76e87324ca1e9c754e8f28a8ef294dd0 to your computer and use it in GitHub Desktop.
Command line program to get the contents of a Notes.app note
#!/bin/bash
# Author: Yotam Gingold <yotam (strudel) yotamgingold.com>
# License: Public Domain [CC0](http://creativecommons.org/publicdomain/zero/1.0/)
# On GitHub as a gist: https://gist.github.com/yig/76e87324ca1e9c754e8f28a8ef294dd0
usage()
{
echo 1>&2 "Usage:" "$0" '<Notes.app note name>'
exit -1
}
if [ $# -ne 1 ]
then
usage
fi
## sometimes pandoc generates lots of extra blank lines, but textutil does weird things with lists.
osascript -e "tell application \"Notes\" to get body of (first note whose name is \"$1\")" | \
pandoc --from=html --to=plain
# textutil -format html -inputencoding UTF-8 -convert txt -stdin -stdout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment