You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
628 B
Bash
29 lines
628 B
Bash
#!/usr/bin/env bash
|
|
|
|
calindx="$HOME/.local/share/calcurse/.env"
|
|
todoitems=$(calcurse --todo=1 --format-todo="%m\n"| tail -n +2 )
|
|
readarray -t todolist <<<$todoitems
|
|
|
|
# get index
|
|
if [[ ! -f "$calindx" ]] ; then
|
|
echo "INDEX=0" > "$calindx"
|
|
fi
|
|
|
|
source "$calindx"
|
|
|
|
if [[ "$1" == "inc" ]] ; then
|
|
((INDEX+=1))
|
|
if [[ $INDEX -ge ${#todolist[@]} ]] ; then
|
|
INDEX=0 # loops
|
|
fi
|
|
fi
|
|
|
|
if [[ "$1" == "dec" ]] ; then
|
|
((INDEX-=1))
|
|
if [[ $INDEX -lt 0 ]] ; then
|
|
INDEX=$((${#todolist[@]}-1))
|
|
fi
|
|
fi
|
|
echo "INDEX=$INDEX" > "$calindx"
|
|
printf '%s (%d/%d)\n' "${todolist[$INDEX]}" $(($INDEX+1)) ${#todolist[@]}
|