Last active
December 30, 2015 02:28
-
-
Save kaz-utashiro/7762629 to your computer and use it in GitHub Desktop.
.greplrc definition to search iCal data and display in single line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################################### | |
# iCal | |
###################################################################### | |
option --ical_data \ | |
--chdir ~/Library/Calendars/*.caldav/*.calendar/Events \ | |
--glob *.ics | |
help --ical Search iCal data | |
option --ical \ | |
--all \ | |
--ical_data \ | |
--print print_ical_line | |
__CODE__ | |
sub print_ical_line { | |
s/\r//g; | |
my $s = ''; | |
my(@s, @e); | |
if (@s = /^DTSTART.*(\d{4})(\d\d)(\d\d)(?:T(\d\d)(\d\d))?/m) { | |
$s .= "$1/$2/$3"; | |
$s .= " $4:$5" if defined $4; | |
} | |
if (@e = /^DTEND.*(\d{4})(\d\d)(\d\d)(?:T(\d\d)(\d\d))?/m) { | |
if ($s[0] eq $e[0] and $s[1] eq $e[1] and $s[2]+1 >= $e[2]) { | |
$s .= "-$4:$5" if defined $4; | |
} else { | |
$s .= "-"; | |
$s .= "$1/" if $s[0] ne $e[0]; | |
$s .= "$2/$3"; | |
} | |
} | |
$s .= " "; | |
/^SUMMARY:(.*)/m and $s .= $1; | |
/^LOCATION:(.*)/m and $s .= " \@[$1]"; | |
$s .= "\n"; | |
$s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment