Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show today's events in terminal using Applescript and Shell

I'm looking to create a simple CLI tool to view today's events. Eventually I want to extend the scope but starting simple.

What I have currnently:

echo "set today to (current date)

tell application \"Calendar\"
    tell calendar \"[email protected]\"
        set curr to every event whose start date is greater than or equal to today
    end tell
end tell" | osascript 

and this gives output:

event id A2794321-6987-4DE0-BC70-DD75FFD5D770 of calendar id 87CF6FE8-B408-4931-8734-FDCBD95857C5, event id A62028B5-9F20-49F0-8660-94A55DC3E2BF of calendar id 87CF6FE8-B408-4931-8734-FDCBD95857C5

I am wondering if I could get some help on extending the shell script to output the events into a list with time and description etc!

Thanks :)

like image 780
user2656127 Avatar asked Oct 17 '25 04:10

user2656127


1 Answers

If you don't need to see recurring events:

set d to current date
set hours of d to 0
set minutes of d to 0
set seconds of d to 0
set out to ""
tell application "Calendar" to tell calendar "Calendar Name"
    repeat with e in (events where start date > d - 1 and start date < d + 86400)
        set out to out & time string of (get start date of e) & " " & ¬
            time string of (get end date of e) & " " & ¬
            summary of e & linefeed
    end repeat
end tell
like image 134
Lri Avatar answered Oct 18 '25 23:10

Lri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!