From 9674fc1c8186a028391daaabfe3c5d738651a8d1 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 11 Apr 2023 14:50:12 +0800 Subject: Update --- bin/task/context | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bin/task/context') diff --git a/bin/task/context b/bin/task/context index 44193d0..6642699 100755 --- a/bin/task/context +++ b/bin/task/context @@ -7,6 +7,9 @@ LOG_FILE=~/log/.context && touch $LOG_FILE PLAN_FILE=~/log/plan.context.md +PROC=$$ +trap 'exit 1' 10 + context="$(cat ~/.task/context)" [[ "$*" =~ '-s' ]] && SET=true && shift time="$1" @@ -27,6 +30,8 @@ _get_seconds() { hour=$(grep -o '[0-9.]\+h' <<<"$1" | tr -d '[:alpha:]') min=$(grep -o '[0-9.]\+m' <<<"$1" | tr -d '[:alpha:]') sec=$(grep -o '[0-9.]\+s' <<<"$1" | tr -d '[:alpha:]') + + [ -z "$hour$min$sec" ] && kill -10 $PROC echo "${hour:-0}*3600 + ${min:-0}*60 + ${sec:-0}" | bc | xargs printf '%.0f\n' } -- cgit v1.2.3-70-g09d2