Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Commands/Add to Calendar.tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env bash
set -euo pipefail

TMP="$(mktemp -t tm-ical.XXXXXX).ics"
ICS_PATH="$TMP"
cat - &gt; "$ICS_PATH"

if ! grep -m1 -q '^BEGIN:VCALENDAR' "$ICS_PATH"; then
echo "Not an iCalendar (.ics) file: missing BEGIN:VCALENDAR" &gt;&amp;2
exit 1
fi

open "$ICS_PATH"
</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>@r</string>
<key>name</key>
<string>Add to Calendar</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>toolTip</string>
<key>scope</key>
<string>source.icalendar</string>
<key>uuid</key>
<string>63D566BE-B906-41C6-8019-5D43BE5C79ED</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>