-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsynctodo.sh
More file actions
executable file
·66 lines (54 loc) · 1.82 KB
/
Copy pathsynctodo.sh
File metadata and controls
executable file
·66 lines (54 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
MAC_TELEKASTEN="/tmp/reminders_Telekasten.txt"
VAULT="/Users/lucas/zettelkasten"
DELIM="zettelkasten"
if ! command -v reminders &> /dev/null
then
echo "Please install 'reminders' from https://github.com/keith/reminders-cli"
exit
fi
if ! reminders show-lists |grep -q "Telekasten"; then
echo "Please create 'Telekasten' list in Mac Reminders manually."
exit
fi
reminders show Telekasten > $MAC_TELEKASTEN
rg -N -e "^- \[[ ]\]" $VAULT|sed 's/- \[[ xX]\] //g' | while read -r line;
do
list=`echo $line | awk -F'.md:' '{print $1}' | awk -F"$DELIM\/" '{print $NF}'`
item=`echo $line | awk -F'.md:' '{print $2}'`
item=`echo $item | sed 's/\[/【/g'|sed 's/\]/】/g'`
if ! grep -q "^[0-9]*: $list:$item$" $MAC_TELEKASTEN; then
reminders add Telekasten "$list:$item"
fi
done
rg -N -e "^- \[[xX]\]" $VAULT/|sed 's/- \[[ xX]\] //g' | while read -r line;
do
list=`echo $line | awk -F'.md:' '{print $1}' | awk -F"$DELIM\/" '{print $NF}'`
item=`echo $line | awk -F'.md:' '{print $2}'`
item=`echo $item | sed 's/\[/【/g'|sed 's/\]/】/g'`
grep "^[0-9]*: $list:$item$" $MAC_TELEKASTEN | while read -r mac_line;
do
ID=`echo $mac_line | cut -d: -f1`
reminders complete Telekasten $ID
done
done
reminders show Telekasten > $MAC_TELEKASTEN
cat $MAC_TELEKASTEN |sed 's/^[0-9]*: //' | while read -r line;
do
list="Reminders"
item="unknown"
if [[ $line =~ [:] ]]; then
list=`echo $line | sed 's/:.*//'`
item=`echo $line | sed 's/^[^:]*://'`
item=`echo $item | sed 's/【/\[/g'|sed 's/】/\]/g'`
else
list="Reminders"
item=$line
fi
md=$VAULT/$list.md
blank_patterned_item=`echo $item | sed 's/ / \*/g' |sed 's/\[/\\\[/g'|sed 's/\]/\\\]/g' `
if ! grep -q "\- \[[ xX]\] $blank_patterned_item" "$md"; then
echo "Add $item to $list.md"
echo "- [ ] $item" >> "$md"
fi
done