Timew|task: Exit function if cmd is unavailable

This commit is contained in:
Jeremy Gardais 2021-10-07 18:05:56 +02:00
parent c13951a8bb
commit c37b5ae6df
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 20 additions and 20 deletions

40
zshrc
View File

@ -409,14 +409,14 @@ alias taperso="task +perso | head"
function tase() { function tase() {
local search="" local search=""
for i; do; search="$search /$i/"; done; for i; do; search="$search /$i/"; done;
task rc.search.case.sensitive:no $search all; task rc.search.case.sensitive:no $search all || return 0
} }
## }}} ## }}}
## search a task by it's name (case SENSITIVE) {{{ ## search a task by it's name (case SENSITIVE) {{{
function tasec() { function tasec() {
local search="" local search=""
for i; do; search="$search /$i/"; done; for i; do; search="$search /$i/"; done;
task $search all; task $search all || return 0
} }
## }}} ## }}}
@ -429,72 +429,72 @@ zstyle ':completion:*:*:task:*' group-name ''
## Display tasks of today {{{ ## Display tasks of today {{{
function tiday() { function tiday() {
if [ "${#}" -eq 0 ]; then if [ "${#}" -eq 0 ]; then
timew summary :day :ids timew summary :day :ids || return 0
else else
timew summary :day :ids "${*}" timew summary :day :ids "${*}" || return 0
fi fi
} }
## }}} ## }}}
## Display tasks of last day {{{ ## Display tasks of last day {{{
function tilastday() { function tilastday() {
if [ "${#}" -eq 0 ]; then if [ "${#}" -eq 0 ]; then
timew summary :yesterday :ids timew summary :yesterday :ids || return 0
else else
timew summary :yesterday :ids "${*}" timew summary :yesterday :ids "${*}" || return 0
fi fi
} }
## }}} ## }}}
## Display tasks of this week {{{ ## Display tasks of this week {{{
function tiweek() { function tiweek() {
if [ "${#}" -eq 0 ]; then if [ "${#}" -eq 0 ]; then
timew summary :week :ids timew summary :week :ids || return 0
else else
timew summary :week :ids "${*}" timew summary :week :ids "${*}" || return 0
fi fi
} }
## }}} ## }}}
## Display tasks of last week {{{ ## Display tasks of last week {{{
function tilastweek() { function tilastweek() {
if [ "${#}" -eq 0 ]; then if [ "${#}" -eq 0 ]; then
timew summary :lastweek :ids timew summary :lastweek :ids || return 0
else else
timew summary :lastweek :ids "${*}" timew summary :lastweek :ids "${*}" || return 0
fi fi
} }
## }}} ## }}}
## Display tasks of this month {{{ ## Display tasks of this month {{{
function timonth() { function timonth() {
if [ "${#}" -eq 0 ]; then if [ "${#}" -eq 0 ]; then
timew summary :month :ids timew summary :month :ids || return 0
else else
timew summary :month :ids "${*}" timew summary :month :ids "${*}" || return 0
fi fi
} }
## }}} ## }}}
## Display tasks of last month {{{ ## Display tasks of last month {{{
function tilastmonth() { function tilastmonth() {
if [ "${#}" -eq 0 ]; then if [ "${#}" -eq 0 ]; then
timew summary :lastmonth :ids timew summary :lastmonth :ids || return 0
else else
timew summary :lastmonth :ids "${*}" timew summary :lastmonth :ids "${*}" || return 0
fi fi
} }
## }}} ## }}}
## Display tasks of this year {{{ ## Display tasks of this year {{{
function tiyear() { function tiyear() {
if [ "${#}" -eq 0 ]; then if [ "${#}" -eq 0 ]; then
timew summary :year :ids timew summary :year :ids || return 0
else else
timew summary :year :ids "${*}" timew summary :year :ids "${*}" || return 0
fi fi
} }
## }}} ## }}}
## Display tasks of last year {{{ ## Display tasks of last year {{{
function tilastyear() { function tilastyear() {
if [ "${#}" -eq 0 ]; then if [ "${#}" -eq 0 ]; then
timew summary :lastyear :ids timew summary :lastyear :ids || return 0
else else
timew summary :lastyear :ids "${*}" timew summary :lastyear :ids "${*}" || return 0
fi fi
} }
## }}} ## }}}
@ -511,7 +511,7 @@ function tidouble() {
else else
## If no argument or more than one ## If no argument or more than one
## Ask the user to choose an ID in tasks from the yesterday {{{ ## Ask the user to choose an ID in tasks from the yesterday {{{
timew summary from yesterday :ids timew summary from yesterday :ids || return 0
printf '%b' "Enter the ${MAGENTAB}ID${RESET} of the task to double spent time should be doubled : " printf '%b' "Enter the ${MAGENTAB}ID${RESET} of the task to double spent time should be doubled : "
read -r tidouble_task_id read -r tidouble_task_id
@ -551,7 +551,7 @@ function tirm() {
else else
## If no argument or more than one ## If no argument or more than one
## Ask the user to choose an ID in tasks from the yesterday {{{ ## Ask the user to choose an ID in tasks from the yesterday {{{
timew summary from yesterday :ids timew summary from yesterday :ids || return 0
printf '%b' "Enter the ${MAGENTAB}ID${RESET} of the task to delete : " printf '%b' "Enter the ${MAGENTAB}ID${RESET} of the task to delete : "
read -r tirm_task_id read -r tirm_task_id