Sophie Hirn 2 years ago
parent
commit
f7434375fe
2 changed files with 28 additions and 10 deletions
  1. +6
    -6
      .bashrc.d/97-todo.sh
  2. +22
    -4
      .local/bin/todo-sort

+ 6
- 6
.bashrc.d/97-todo.sh View File

@@ -8,22 +8,22 @@ alias todo="$ex"
if [ -n "$ex" ] && [ -f "$HOME/todo.cfg" ] && [ -z "$BASHRC_NOFANCIES" ]; then
sched="$($ex ls -+project -+shopping | grep -v 'sched:0$')"
echo "Small:"
echo "$sched" | grep '+S' | sed 's:^: :'
echo "$sched" | grep '+S' | tac | sed 's:^: :'
echo
echo "Medium:"
echo "$sched" | grep '+M' | sed 's:^: :'
echo "$sched" | grep '+M' | tac | sed 's:^: :'
echo
echo "Large:"
echo "$sched" | grep '+L' | sed 's:^: :'
echo "$sched" | grep '+L' | tac | sed 's:^: :'
echo
echo "Huge:"
echo "$sched" | grep '+XL' | sed 's:^: :'
echo "$sched" | grep '+XL' | tac | sed 's:^: :'
echo
echo "Other:"
echo "$sched" | grep -v -e '+S' -e '+M' -e '+L' -e '+XL' | sed 's:^: :'
echo "$sched" | grep -v -e '+S' -e '+M' -e '+L' -e '+XL' | tac | sed 's:^: :'
echo
echo "Most important right now:"
echo "$sched" | tail -n 3 | sed 's:^: :'
echo "$sched" | tail -n 3 | tac | sed 's:^: :'
echo

fi

+ 22
- 4
.local/bin/todo-sort View File

@@ -26,6 +26,18 @@ function creat_date() {
fi
}

function t_date() {
( echo "$1" | grep -o "t:$datefmt" | grep -o "$datefmt" ) || echo
}

function start_date() {
local d="$(t_date "$1")"
if [ -z "$d" ]; then
d="$(creat_date "$1")"
fi
echo "$d"
}

function compl_date() {
local tmp="$(echo "$1" | sed -r "s:$match:\5:")"
if [ -n "$tmp" ]; then
@@ -89,16 +101,22 @@ function rating() {
;;
esac

local creat=$(creat_date "$1")
local start=$(start_date "$1")
local now=$(date '+%Y-%m-%d')
local age=$(datediff "$now" "$creat")
local age=$(datediff "$now" "$start")

echo "sched_age:$age"
if [ "$age" -ge 0 ]; then
echo "sched_age:$age"
else
echo "sched_future:1"
echo 1
return
fi

local due=$(due_date "$1")
local due_fact
if [ -n "$due" ]; then
local period=$(datediff "$due" "$creat")
local period=$(datediff "$due" "$start")

if [ "$period" -le 0 ]; then
due_fact=$weight_overdue

Loading…
Cancel
Save