Created
December 9, 2020 07:42
-
-
Save kiselev-nikolay/6edcea339521aa2c89990a39d6bdfd40 to your computer and use it in GitHub Desktop.
Todoist terminal intergration
This file contains hidden or 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
| token="YOUR_TODOIST_TOKEN_HERE" | |
| nowt=$(expr $(date +%s) / 14400) | |
| test -f /tmp/todoistTasks$nowt.json \ | |
| || curl --silent -q https://api.todoist.com/sync/v8/sync \ | |
| -d token=$token \ | |
| -d sync_token='*' \ | |
| -d resource_types='["items"]' > /tmp/todoistTasks$nowt.json | |
| printf "\033[1;32mTasks need to be done:\033[0m\n" | |
| cat /tmp/todoistTasks$nowt.json | python3 -c " | |
| import sys, json, datetime | |
| data = json.load(sys.stdin) | |
| todos = [] | |
| red, orange, blue = '\033[0;31m', '\033[0;33m', '\033[0;36m' | |
| reset = '\033[m' | |
| for t in data['items']: | |
| content = t['content'][:60] | |
| if len(t['content']) > 60: | |
| content = content + '...' | |
| priority = ('X' * t['priority']).ljust(4, '-') | |
| if priority == 'XXXX': | |
| priority = red + priority + reset | |
| if priority == 'XXX-': | |
| priority = orange + priority + reset | |
| if priority == 'XX--': | |
| priority = blue + priority + reset | |
| if t['due'] is None: | |
| continue | |
| due_datetime = datetime.datetime.fromisoformat(t['due']['date']) | |
| due_day = due_datetime.strftime('%Y-%m-%d') | |
| now_datetime = datetime.datetime.now() | |
| now_day = now_datetime.strftime('%Y-%m-%d') | |
| if now_day == due_day: | |
| todos.append(' '.join((' ', ' ', priority, content))) | |
| elif now_datetime > due_datetime: | |
| todos.append(' '.join((' ', red + 'o' + reset, priority, content))) | |
| todos.sort() | |
| print(*todos, sep='\n') | |
| " | |
| printf "\n\033[0;30mhttps://todoist.com/app/#/today\033[0m\n" |
Author
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

To use it:
Move file to bin
sudo mv todoist.sh /usr/bin/todoist.shChange access rules
sudo chmod 511 /usr/bin/todoist.shAdd following to bashrc or zshrc file