-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtodo
executable file
·64 lines (48 loc) · 2.6 KB
/
todo
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
#!/usr/bin/fish
# Wunderlist CLI for adding todos
# ===============================
# Decription
# ----------
# Wrapper for [wl](https://github.com/robdimsdale/wl/releases) for adding todos with more convenient syntax
# [Read More](http://developer.run/15)
# Author: [Dmitry](http://dmi3.net) [Source](https://github.com/dmi3/bin)
# Instalation
# -----------
# 1. ⚠ Make sure [Fish shell](http://fishshell.com/#platform_tabs) > 2.3.0
# 2. `curl https://raw.githubusercontent.com/dmi3/bin/master/todo --create-dirs -o ~/bin/todo`
# 3. `curl https://raw.githubusercontent.com/dmi3/bin/master/config/fish/completions/todo.fish --create-dirs -o ~/.config/fish/completions/todo.fish`
# 4. <https://developer.wunderlist.com/apps>
# 5. `[CREATE APP]` (Put https://wunderlist.com to both `APP URL` and `AUTH CALLBACK URL`)
# 6. Set enviroment variables in this script ↓ (line 31)
# 7. Add more list shortcuts ↓ (line 39)
# Usage
# -----
# todo buy stuff --life --on next monday
# todo resolve issue --work --star
# todo --work meet customer --on jan 7
set -x WL_CLIENT_ID 0000000 # CLIENT ID from https://developer.wunderlist.com/apps
set -x WL_ACCESS_TOKEN 0000000 # [CREATE ACCESS TOKEN] in https://developer.wunderlist.com/apps
set LIST 0000000 # Default list (get id by running `wl inbox`)
set STAR false
set DATEFMT "+%Y-%m-%d"
set DATE (date $DATEFMT)
contains -- "--life" $argv; and set LIST 0000000
contains -- "--work" $argv; and set LIST 0000000
# Add more lists here (use `wl lists` to get ids)
contains -- "--star" $argv; and set STAR true
contains -- "--tomorrow" $argv; and set DATE (date $DATEFMT --date="tomorrow")
contains -- "--on" $argv; and set DATE (date $DATEFMT --date=(string replace -r -- ".*--on\s" "" "$argv")) # date --date="next Friday"
set TITLE (string replace -ra "\-\-\w*\s?" "" -- "$argv" | string trim) #remove arguments starting with --
math (echo $version | tr -d .)"<231" > /dev/null; and echo "⚠ Please upgrade fish shell to at least 2.3.0"
if not type -q wl
set WL_VERSION (curl -Ls -o /dev/null -w "%{url_effective}" https://github.com/robdimsdale/wl/releases/latest | xargs basename | string trim -c "v")
echo "⚠ wl is not found. Installing $WL_VERSION."
curl -L https://github.com/robdimsdale/wl/releases/download/v$WL_VERSION/wl-linux-amd64-$WL_VERSION -o /tmp/wl
chmod +x /tmp/wl; sudo -p "Root password to install wl: " mv /tmp/wl /usr/local/bin/wl;
end
set result (wl create-task --title="$TITLE" --dueDate=$DATE --listID=$LIST --starred=$STAR)
if test $status -eq 0
echo $result | grep 'title\|starred\|due_date'
else
echo $result
end