-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo_today_md.sh
More file actions
27 lines (22 loc) · 944 Bytes
/
todo_today_md.sh
File metadata and controls
27 lines (22 loc) · 944 Bytes
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
#!/bin/sh
# Set IFS to handle spaces in task descriptions and tags
IFS=$(printf '\n\t')
# Export all next tasks as JSON and store in variable
tasks=$(task export next | jq -c '.[]')
# Sort tasks by urgency and take the top 3
top3=$(echo "$tasks" | jq -s 'sort_by(.urgency) | reverse | .[0:3]')
# Loop through the top 3 tasks and print them
for task in $(echo "$top3" | jq -c '.[]'); do
description=$(echo "$task" | jq -r '.description')
project=$(echo "$task" | jq -r '.project')
due=$(echo "$task" | jq -r '.due')
tags=$(echo "$task" | jq -r '.tags | @csv' | tr -d '"' | sed 's/,/, #/g')
# Convert due date to human-readable format
if [[ -n "$due" && "$due" != "null" ]]; then
timestamp=$(date -j -f "%Y%m%dT%H%M%SZ" "$due" '+%Y-%m-%d')
due="Due: $timestamp"
else
due="No date"
fi
printf -- "- [ ] %s (%s, Project: %s, Tags: #%s)\n" "$description" "$due" "$project" "$tags"
done