From c37b5ae6dfbcf73c23e08eebdcaacf93d5d71ebd Mon Sep 17 00:00:00 2001 From: Gardouille Date: Thu, 7 Oct 2021 18:05:56 +0200 Subject: [PATCH] Timew|task: Exit function if cmd is unavailable --- zshrc | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/zshrc b/zshrc index db3879e..e01d87a 100644 --- a/zshrc +++ b/zshrc @@ -409,14 +409,14 @@ alias taperso="task +perso | head" function tase() { local search="" 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) {{{ function tasec() { local search="" 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 {{{ function tiday() { if [ "${#}" -eq 0 ]; then - timew summary :day :ids + timew summary :day :ids || return 0 else - timew summary :day :ids "${*}" + timew summary :day :ids "${*}" || return 0 fi } ## }}} ## Display tasks of last day {{{ function tilastday() { if [ "${#}" -eq 0 ]; then - timew summary :yesterday :ids + timew summary :yesterday :ids || return 0 else - timew summary :yesterday :ids "${*}" + timew summary :yesterday :ids "${*}" || return 0 fi } ## }}} ## Display tasks of this week {{{ function tiweek() { if [ "${#}" -eq 0 ]; then - timew summary :week :ids + timew summary :week :ids || return 0 else - timew summary :week :ids "${*}" + timew summary :week :ids "${*}" || return 0 fi } ## }}} ## Display tasks of last week {{{ function tilastweek() { if [ "${#}" -eq 0 ]; then - timew summary :lastweek :ids + timew summary :lastweek :ids || return 0 else - timew summary :lastweek :ids "${*}" + timew summary :lastweek :ids "${*}" || return 0 fi } ## }}} ## Display tasks of this month {{{ function timonth() { if [ "${#}" -eq 0 ]; then - timew summary :month :ids + timew summary :month :ids || return 0 else - timew summary :month :ids "${*}" + timew summary :month :ids "${*}" || return 0 fi } ## }}} ## Display tasks of last month {{{ function tilastmonth() { if [ "${#}" -eq 0 ]; then - timew summary :lastmonth :ids + timew summary :lastmonth :ids || return 0 else - timew summary :lastmonth :ids "${*}" + timew summary :lastmonth :ids "${*}" || return 0 fi } ## }}} ## Display tasks of this year {{{ function tiyear() { if [ "${#}" -eq 0 ]; then - timew summary :year :ids + timew summary :year :ids || return 0 else - timew summary :year :ids "${*}" + timew summary :year :ids "${*}" || return 0 fi } ## }}} ## Display tasks of last year {{{ function tilastyear() { if [ "${#}" -eq 0 ]; then - timew summary :lastyear :ids + timew summary :lastyear :ids || return 0 else - timew summary :lastyear :ids "${*}" + timew summary :lastyear :ids "${*}" || return 0 fi } ## }}} @@ -511,7 +511,7 @@ function tidouble() { else ## If no argument or more than one ## 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Ā : " read -r tidouble_task_id @@ -551,7 +551,7 @@ function tirm() { else ## If no argument or more than one ## 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Ā : " read -r tirm_task_id