]> arthur.barton.de Git - ax-zsh.git/blob - plugins/icalbuddy/icalbuddy.zshrc
icalbuddy, remind: Don't run for "axzshctl check-plugins"
[ax-zsh.git] / plugins / icalbuddy / icalbuddy.zshrc
1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # icalbuddy.zshrc: Show reminders using icalBuddy(1).
3
4 # Make sure that "icalBuddy(1)" is installed.
5 (( $+commands[icalBuddy] )) || return 1
6
7 # Don't run this plugin on "check-plugins"!
8 [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 0
9
10 # Check if reminders have been shown during last 60 minutes, and if so,
11 # don't show them now but return.
12 [[ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]] || return 0
13
14 tmpfile=$(mktemp ${TMPDIR:-/tmp}/icalbuddy.XXXXXX) || return 1
15
16 if axzsh_is_utf_terminal; then
17         bul="•"; bul_imp="!"; sep="»"
18 else
19         bul="*"; bul_imp="!"; sep=">"
20 fi
21
22 # Show reminders now.
23 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
24         -nc -npn -iep "title,due" -stda \
25         tasksDueBefore:today 2>/dev/null >>"$tmpfile"
26 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
27         -nc -npn -iep "title,datetime" \
28         eventsToday+1 2>/dev/null  >>"$tmpfile"
29
30 if [[ -s "$tmpfile" ]]; then
31         echo; cat "$tmpfile"; echo
32 fi
33
34 rm -f "$tmpfile"
35 unset bul bul_imp sep tmpfile
36
37 # Wtite "stamp" file.
38 [[ -w ~/ ]] && touch ~/.last_reminder