Last active
March 8, 2017 18:17
-
-
Save matthiasbeyer/84fb492164ea84e96a21 to your computer and use it in GitHub Desktop.
remind entry to ics with selection
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
#!/bin/bash | |
# | |
# The following script is a ugly hack. But it works, so yeah \m/ | |
# | |
# It uses awk, cut, head, tail, rem2ics and fzf (whereas this is only for the | |
# selection-process and could be replaced). | |
# | |
# Purpose: | |
# | |
# Let the user select one of his remind calendar entries (nicely formatted, though) | |
# and export this entry to ics. | |
# | |
# Note: | |
# The format the script prints in the selection process is the following: | |
# | |
# <number> | <date> | <time (optional)> | <description> | |
# | |
# The number is lateron used to re-retreive the entry from remind. If the calendar | |
# in remind changes in between, this WON'T WORK. | |
# | |
# License | |
# | |
# Licensed under MIT | |
# (c) Matthias Beyer | |
# | |
select_entry() { | |
rem -s | awk ' | |
function fmtdate(d) { | |
return gensub(/([0-9]{4})\/([0-9]{2})\/([0-9]{2})/, "\\3-\\2-\\1", "", d); | |
} | |
function extract(str,x) { | |
return gensub(/(.*)(([0-9]+|\*)\ )+(|([0-9]+:[0-9]+[apm]*-[0-9]+:[0-9]+[apm]*)) *(.*)/, x, "", str); | |
} | |
function extractDesc(str) { | |
return extract(str, "\\6"); | |
} | |
function extractTime(str) { | |
return extract(str, "\\4"); | |
} | |
BEGIN { | |
n=1; | |
} | |
{ | |
printf "%i ", n | |
for (nl = length(n); nl < 5; nl++) { | |
printf " " | |
} | |
printf "| " | |
n++; | |
printf "%s | ", fmtdate($1) | |
if (length(extractTime($0)) == 0) { | |
for(i=0;i<=14;i++) { | |
printf " " | |
} | |
} else { | |
t = extractTime($0) | |
l = length(t) | |
printf "%s", extractTime($0) | |
for(;l<15;l++) { | |
printf " " | |
} | |
} | |
printf " | %s\n", extractDesc($0); | |
} | |
' | fzf | cut -d " " -f 1 | |
} | |
n=$(select_entry) | |
rem -s | head -n $n | tail -n 1 | rem2ics -do 2>/dev/null > attachement.ics |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment