Skip to content

Instantly share code, notes, and snippets.

@Pe8er
Last active April 20, 2018 20:33
Show Gist options
  • Save Pe8er/9b791268a2b56305f9716f35e47da585 to your computer and use it in GitHub Desktop.
Save Pe8er/9b791268a2b56305f9716f35e47da585 to your computer and use it in GitHub Desktop.
set nextEvent to do shell script "~/.dotfiles/bin/icalBuddy -ec 'Found in Natural Language' -npn -nc -iep 'title,datetime,location' -eed -ea -n -li 1 -ps '| @& |' -b '' eventsToday"
log nextEvent
if nextEvent is not "" then
set AppleScript's text item delimiters to " @& "
set itemCount to count of text items of nextEvent
--log itemCount
if itemCount is 1 then
set eventName to "Event"
set eventTime to nextEvent
else if itemCount is 2 then
set eventName to nextEvent's text item 1
set eventTime to nextEvent's text item 2
else if itemCount is 3 then
set eventName to nextEvent's text item 1
set eventTime to nextEvent's text item 3
end if
set AppleScript's text item delimiters to ""
if eventName's length > 20 then set eventName to eventName's items 1 thru 20 & "…" as string
if eventTime's length > 20 then set eventTime to eventTime's items 1 thru 20 & "…" as string
set nextEvent to eventName & " at " & eventTime
end if
return nextEvent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment