aboutsummaryrefslogtreecommitdiffstats
path: root/.functions
diff options
context:
space:
mode:
authorSindre Sorhus <sindresorhus@gmail.com>2013-05-10 01:55:45 +0200
committerMathias Bynens <mathias@qiwi.be>2013-05-10 08:33:58 +0200
commitb63c7613d0f2619a03f667ae7ff719306462ad23 (patch)
treee7f7cc5cfe2e221984a4e4f87a2025b8e0685662 /.functions
parent5a44681edcac0b137ddaa6523af8d7fa6747550d (diff)
downloaddotfiles-b63c7613d0f2619a03f667ae7ff719306462ad23.tar.gz
dotfiles-b63c7613d0f2619a03f667ae7ff719306462ad23.tar.bz2
dotfiles-b63c7613d0f2619a03f667ae7ff719306462ad23.zip
.functions: Improve `note`
Give the Notes.app function the ability to add both `title` and `body`. Closes #203.
Diffstat (limited to '.functions')
-rw-r--r--.functions18
1 files changed, 10 insertions, 8 deletions
diff --git a/.functions b/.functions
index ca55c46..5a2788b 100644
--- a/.functions
+++ b/.functions
@@ -195,20 +195,22 @@ function getcertnames() {
}
# Add note to Notes.app (OS X 10.8)
-# Usage: `note 'foo'` or `echo 'foo' | note`
+# Usage: `note 'title' 'body'` or `echo 'body' | note`
+# Title is optional
function note() {
- local text
- if [ -t 0 ]; then # argument
- text="$1"
- else # pipe
- text=$(cat)
+ local title
+ local body
+ if [ -t 0 ]; then
+ title="$1"
+ body="$2"
+ else
+ title=$(cat)
fi
- body=$(echo "$text" | sed -E 's|$|<br>|g')
osascript >/dev/null <<EOF
tell application "Notes"
tell account "iCloud"
tell folder "Notes"
- make new note with properties {name:"$text", body:"$body"}
+ make new note with properties {name:"$title", body:"$title" & "<br><br>" & "$body"}
end tell
end tell
end tell