Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
.greplrc definition to search iCal data and display in single line
######################################################################
# 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
You can’t perform that action at this time.