From 8ed0257572cf00acd94c9768dc10f9f7e660cf0b Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 29 Jul 2012 17:05:18 +0200 Subject: .functions: Add `note` and `remind` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `note` quickly adds a note to Notes.app, and `remind` adds a reminder to — you guessed it — Reminders.app. Both applications are available on OS X 10.8. Note that in order for `note` to work, iCloud sync must be enabled for Notes.app. --- .functions | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to '.functions') diff --git a/.functions b/.functions index a544dfd..45100d6 100644 --- a/.functions +++ b/.functions @@ -45,13 +45,12 @@ function gurl() { } # Syntax-highlight JSON strings or files +# Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json` function json() { - if [ -p /dev/stdin ]; then - # piping, e.g. `echo '{"foo":42}' | json` - python -mjson.tool | pygmentize -l javascript - else - # e.g. `json '{"foo":42}'` + if [ -t 0 ]; then # argument python -mjson.tool <<< "$*" | pygmentize -l javascript + else # pipe + python -mjson.tool | pygmentize -l javascript fi } @@ -78,6 +77,45 @@ function codepoint() { echo # newline } +# Add note to Notes.app (OS X 10.8) +# Usage: `note 'foo'` or `echo 'foo' | note` +function note() { + local text + if [ -t 0 ]; then # argument + text="$1" + else # pipe + text=$(cat) + fi + body=$(echo "$text" | sed -E 's|$|
|g') + osascript >/dev/null </dev/null <