task - track start and finish of a task

Submitted scripts and programs
Forum rules
Your own work only.
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

task - track start and finish of a task

Unread post by machinebacon » Sun Dec 21, 2014 3:03 am

To track when you started and finished a task, you can use this script.

task start my_task
<do your shit>
task stop my_task
cat task-*

If you have a ~/tasks directory, the file will be put there. Nothing fancy (yes, I know, (org-clock-persistence-insinuate), let's keep it simple ;)

Code: Select all

#!/bin/bash

# task - a task timetracking wrapper
#
# COMMANDS:
# task start <TASKNAME>
# task stop <TASKNAME>
#
# creates a task-TASKNAME-DATE file and adds start and stop time stamps
#

# set up environment

TASKPATH="/home/$USER"
TASKNAME="$2"
TIMESTAMP="`date +%R`"
COMMAND="$1"

# check for ~/tasks directory
# if directory exists, put tasks there
if [ -d "/home/$USER/tasks" ]; then
    TASKPATH="/home/$USER/tasks"
    echo "$TASKNAME filed in $TASKPATH"
fi

# finally set the damned filename
FILENAME="$TASKPATH/task-$2-`date +%F`"

# read start from input
if [ "$COMMAND" = "start" ]; then
    echo "$TIMESTAMP $TASKNAME started" >> $FILENAME
fi

# read stop from input
if [ "$COMMAND" = "stop" ]; then
    echo "$TIMESTAMP $TASKNAME finished" >> $FILENAME
fi
..gnutella..

User avatar
stark
MILF
Posts: 521
Joined: Sat Sep 27, 2014 6:38 pm
Location: Arpanet
Contact:

Re: task - track start and finish of a task

Unread post by stark » Sun Dec 21, 2014 8:49 am

Wow, I love the simplicity of this, going to remove the plain todo in dmenu with this. Thanks for the wonderful share bacon :)
If you can do it go ahead and do it, if you can't do it then don't even criticize it. - gingerdesu

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: task - track start and finish of a task

Unread post by machinebacon » Sun Dec 21, 2014 9:01 am

Welcome :) You can even remove the -`date +%F` in the $FILENAME if you just want to track in a single file :)
..gnutella..

User avatar
stark
MILF
Posts: 521
Joined: Sat Sep 27, 2014 6:38 pm
Location: Arpanet
Contact:

Re: task - track start and finish of a task

Unread post by stark » Sun Dec 21, 2014 4:56 pm

^ Thanks Again :D
If you can do it go ahead and do it, if you can't do it then don't even criticize it. - gingerdesu

Post Reply