Taskwarrior: New function to purge a deleted task

This commit is contained in:
Jeremy Gardais 2021-10-11 18:45:00 +02:00
parent 74fcd2744b
commit 1c24842d61
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 39 additions and 1 deletions

40
zshrc
View File

@ -451,7 +451,7 @@ function tadel() {
# Check confirmation # Check confirmation
if printf -- '%s' "${tadel_confirmation:=y}" | grep --quiet --word-regexp -- "y"; then if printf -- '%s' "${tadel_confirmation:=y}" | grep --quiet --word-regexp -- "y"; then
task rc.confirmation:no "${tadel_task_id}" delete task rc.confirmation:no "${tadel_task_id}" delete
printf '%b' "\"${MAGENTAB}${tadel_task_id} ${tadel_task_desc}${RESET}\" task was removed." printf '%b' "\"${MAGENTAB}${tadel_task_id} ${tadel_task_desc}${RESET}\" task was removed.\n"
fi fi
# Unset defined variables # Unset defined variables
@ -459,6 +459,44 @@ function tadel() {
} }
## }}} ## }}}
## Mark a task as done {{{ ## Mark a task as done {{{
function tapurge() {
# Verify argument
if [ "${#}" -eq 0 ]; then
## If no argument
## Ask the user to choose a task description from the deleted tasks list {{{
task all status:deleted || return 0
printf '%b' "Enter few ${MAGENTAB}words matching the description${RESET} of the expected task to purge : "
read -r tapurge_task_regexp
else
## Merge all args into one var
tapurge_task_regexp="${*}"
## }}}
fi
local tapurge_task_desc=$(task "${tapurge_task_regexp}" simpledeleted | grep --after-context=2 -- "^Description" | tail --lines=1 || return 0)
# If no task with this Description exists, exit function {{{
if [ -z "${tapurge_task_desc}" ]; then
printf '%b' "No available task with ${REDB}${tapurge_task_regexp}${RESET} pattern."
return 1
fi
# }}}
printf '%b' "Completly purge the task \"${MAGENTAB}${tapurge_task_desc}${RESET}\" [Y/n] ? "
read -r tapurge_confirmation
# Check confirmation
if printf -- '%s' "${tapurge_confirmation:=y}" | grep --quiet --word-regexp -- "y"; then
task rc.confirmation:no "${tapurge_task_desc}" purge
printf '%b' "\"${MAGENTAB}${tapurge_task_desc}${RESET}\" was purged."
fi
# Unset defined variables
unset tapurge_confirmation tapurge_task_regexp
}
## }}}
## Mark a task as done {{{
function tadone() { function tadone() {
# Verify argument # Verify argument
if [ "${#}" -eq 0 ]; then if [ "${#}" -eq 0 ]; then