]> arthur.barton.de Git - ax-zsh.git/commitdiff
New "icalbuddy" plugin
authorAlexander Barton <alex@barton.de>
Sun, 12 Mar 2017 19:50:08 +0000 (20:50 +0100)
committerAlexander Barton <alex@barton.de>
Sun, 12 Mar 2017 19:50:08 +0000 (20:50 +0100)
Show reminders using the icalBuddy(1) tool on shell startup, but not
more often than once every hour.

plugins/icalbuddy/README.md [new file with mode: 0644]
plugins/icalbuddy/icalbuddy.zshrc [new file with mode: 0644]

diff --git a/plugins/icalbuddy/README.md b/plugins/icalbuddy/README.md
new file mode 100644 (file)
index 0000000..466a1bb
--- /dev/null
@@ -0,0 +1,4 @@
+## icalbuddy
+
+Show reminders using the icalBuddy(1) tool on shell startup, but not more often
+than once every hour.
diff --git a/plugins/icalbuddy/icalbuddy.zshrc b/plugins/icalbuddy/icalbuddy.zshrc
new file mode 100644 (file)
index 0000000..dcc70c6
--- /dev/null
@@ -0,0 +1,35 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# icalbuddy.zshrc: Show reminders using icalBuddy(1).
+
+# Make sure that "icalBuddy(1)" is installed.
+(( $+commands[icalBuddy] )) || return 1
+
+# Check if reminders have been shown during last 60 minutes, and if so,
+# don't show them now but return.
+[[ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]] || return 0
+
+tmpfile=$(mktemp ${TMPDIR:-/tmp}/icalbuddy.XXXXXX) || return 1
+
+if axzsh_is_utf_terminal; then
+       bul="•"; bul_imp="!"; sep="»"
+else
+       bul="*"; bul_imp="!"; sep=">"
+fi
+
+# Show reminders now.
+icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
+       -nc -npn -iep "title,due" -stda \
+       tasksDueBefore:today 2>/dev/null >>"$tmpfile"
+icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
+       -nc -npn -iep "title,datetime" \
+       eventsToday+1 2>/dev/null  >>"$tmpfile"
+
+if [[ -s "$tmpfile" ]]; then
+       echo; cat "$tmpfile"; echo
+fi
+
+rm -f "$tmpfile"
+unset bul bul_imp sep tmpfile
+
+# Wtite "stamp" file.
+[[ -w ~/ ]] && touch ~/.last_reminder