1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # calendar.ax-io: Show calendar(1) entries for the current day.
4 # Make sure that "calendar(1)" is installed.
5 (( $+commands[calendar] )) || return 1
7 # Don't run this plugin on "check-plugins", but test if it would work!
8 # It fails when no calendar files are available, for example, on macOS ...
9 if [[ -n "$AXZSH_PLUGIN_CHECK" ]]; then
10 calendar >/dev/null 2>&1 || return 1
14 # Don't show any info when ~/.hushlogin exists ...
15 [[ -r ~/.hushlogin ]] && return 0
17 # Check if calendar(1) infos have been shown during last 60 minutes, and if so,
18 # don't show them now but return.
19 [[ -z `find "$XDG_CACHE_HOME/axzsh_last_calendar" -mmin -60 2>/dev/null` ]] || return 0
21 tmpfile=$(mktemp "$TMPDIR/calendar.XXXXXX") || return 1
23 calendar -A0 >"$tmpfile"
24 if [[ -s "$tmpfile" ]]; then
30 [[ -w ~/ ]] && touch "$XDG_CACHE_HOME/axzsh_last_calendar"