Fixed & cleaned xbar plugin
This commit is contained in:
parent
5aec5ed3e5
commit
5e52fbd243
1 changed files with 20 additions and 22 deletions
|
@ -19,12 +19,12 @@
|
||||||
PLACEHOLDER_NO_PROJECT='[no project]'
|
PLACEHOLDER_NO_PROJECT='[no project]'
|
||||||
PLACEHOLDER_NO_TASK='[no task]'
|
PLACEHOLDER_NO_TASK='[no task]'
|
||||||
|
|
||||||
if [[ -z "$ZEIT_BIN" ]]
|
if [ -z "$ZEIT_BIN" ]
|
||||||
then
|
then
|
||||||
ZEIT_BIN=$1
|
ZEIT_BIN=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$ZEIT_DB" ]]
|
if [ -z "$ZEIT_DB" ]
|
||||||
then
|
then
|
||||||
export ZEIT_DB=$2
|
export ZEIT_DB=$2
|
||||||
fi
|
fi
|
||||||
|
@ -36,11 +36,11 @@ case $3 in
|
||||||
|
|
||||||
$ZEIT_BIN --no-colors finish
|
$ZEIT_BIN --no-colors finish
|
||||||
|
|
||||||
if [[ "$flag_p" = "$PLACEHOLDER_NO_PROJECT" ]]
|
if [ "$flag_p" = "$PLACEHOLDER_NO_PROJECT" ]
|
||||||
then
|
then
|
||||||
flag_p=''
|
flag_p=''
|
||||||
fi
|
fi
|
||||||
if [[ "$flag_t" = "$PLACEHOLDER_NO_TASK" ]]
|
if [ "$flag_t" = "$PLACEHOLDER_NO_TASK" ]
|
||||||
then
|
then
|
||||||
flag_t=''
|
flag_t=''
|
||||||
fi
|
fi
|
||||||
|
@ -59,59 +59,57 @@ trackingTask=''
|
||||||
trackingDuration=''
|
trackingDuration=''
|
||||||
tracking=$($ZEIT_BIN --no-colors tracking)
|
tracking=$($ZEIT_BIN --no-colors tracking)
|
||||||
|
|
||||||
if [[ "${tracking:3:8}" = "tracking" ]]
|
if echo "$tracking" | grep -q '^ ▶ tracking'
|
||||||
then
|
then
|
||||||
if [[ "${tracking:12:8}" = "task for" ]]
|
if echo "$tracking" | grep -q '^ ▶ tracking task for'
|
||||||
then
|
then
|
||||||
trackingProject=$PLACEHOLDER_NO_PROJECT
|
trackingProject=$PLACEHOLDER_NO_PROJECT
|
||||||
trackingTask=$PLACEHOLDER_NO_TASK
|
trackingTask=$PLACEHOLDER_NO_TASK
|
||||||
trackingDuration=$(echo $tracking | sed -E 's/.*tracking task for (.+)/\1/g')
|
trackingDuration=$(echo "$tracking" | sed -E 's/.*tracking task for (.+)/\1/g')
|
||||||
else
|
else
|
||||||
trackingProject=$(echo $tracking | sed -E 's/.*tracking (.+) on (.+) for (.+)/\2/g')
|
trackingProject=$(echo "$tracking" | sed -E 's/.*tracking (.+) on (.+) for (.+)/\2/g')
|
||||||
trackingTask=$(echo $tracking | sed -E 's/.*tracking (.+) on (.+) for (.+)/\1/g')
|
trackingTask=$(echo "$tracking" | sed -E 's/.*tracking (.+) on (.+) for (.+)/\1/g')
|
||||||
trackingDuration=$(echo $tracking | sed -E 's/.*tracking (.+) on (.+) for (.+)/\3/g')
|
trackingDuration=$(echo "$tracking" | sed -E 's/.*tracking (.+) on (.+) for (.+)/\3/g')
|
||||||
fi
|
fi
|
||||||
tracking=$trackingDuration
|
tracking=$trackingDuration
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $tracking
|
echo "$tracking"
|
||||||
echo '---'
|
echo '---'
|
||||||
echo 'Projects'
|
echo 'Projects'
|
||||||
|
|
||||||
project=''
|
project=''
|
||||||
$ZEIT_BIN --no-colors list --only-projects-and-tasks | while read line
|
$ZEIT_BIN --no-colors list --only-projects-and-tasks | while read -r line
|
||||||
do
|
do
|
||||||
if [[ $line = \◆* ]]
|
if echo "$line" | grep -q '^◆'
|
||||||
then
|
then
|
||||||
project=$(echo $line | sed 's/◆[[:space:]]\{0,1\}//g')
|
project=$(echo "$line" | sed 's/◆[[:space:]]\{0,3\}//g')
|
||||||
|
if [ "$project" = "" ]
|
||||||
if [[ "$project" = "" ]]
|
|
||||||
then
|
then
|
||||||
project=$PLACEHOLDER_NO_PROJECT
|
project=$PLACEHOLDER_NO_PROJECT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$project" = "$trackingProject" ]]
|
if [ "$project" = "$trackingProject" ]
|
||||||
then
|
then
|
||||||
echo "-- ▶ $project"
|
echo "-- ▶ $project"
|
||||||
else
|
else
|
||||||
echo "-- $project"
|
echo "-- $project"
|
||||||
fi
|
fi
|
||||||
elif [[ $line = \└\─\─* ]]
|
elif echo "$line" | grep -q '^└──'
|
||||||
then
|
then
|
||||||
task=$(echo $line | sed 's/└──[[:space:]]\{0,1\}//g')
|
task=$(echo "$line" | sed 's/└──[[:space:]]\{0,3\}//g')
|
||||||
|
|
||||||
if [[ "$task" = "" ]]
|
if [ "$task" = "" ]
|
||||||
then
|
then
|
||||||
task=$PLACEHOLDER_NO_TASK
|
task=$PLACEHOLDER_NO_TASK
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$project" = "$trackingProject" && "$task" = "$trackingTask" ]]
|
if [ "$project" = "$trackingProject" ] && [ "$task" = "$trackingTask" ]
|
||||||
then
|
then
|
||||||
echo "---- ▶ $task | shell='$0' param1='$ZEIT_BIN' param2='$ZEIT_DB' param3=finish param4='$project' param5='$task' terminal=false refresh=true"
|
echo "---- ▶ $task | shell='$0' param1='$ZEIT_BIN' param2='$ZEIT_DB' param3=finish param4='$project' param5='$task' terminal=false refresh=true"
|
||||||
else
|
else
|
||||||
echo "---- $task | shell='$0' param1='$ZEIT_BIN' param2='$ZEIT_DB' param3=track param4='$project' param5='$task' terminal=false refresh=true"
|
echo "---- $task | shell='$0' param1='$ZEIT_BIN' param2='$ZEIT_DB' param3=track param4='$project' param5='$task' terminal=false refresh=true"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
#echo $line | sed 's/◆/--/g' | sed 's/└── \(.*\)/---- \1 \| shell="$0" param1=track param2="\1" terminal=false/g'; done
|
|
||||||
done
|
done
|
||||||
exit
|
exit
|
||||||
|
|
Loading…
Reference in a new issue