zeit icon indicating copy to clipboard operation
zeit copied to clipboard

Add support for "pausing" tracking?

Open khughitt opened this issue 4 years ago • 9 comments

If you can think of a simple way to support "pausing", that could be pretty useful.

Probably just a single command "zeit pause" to toggle it on/off.

On possible approach might be to create create a "pausedCounter", and then, after each pause/unpause, add - to the counter.

Then when zeit finish is called, you can simply check if the counter is non-zero, and if so, subtract that time from the full event duration.

khughitt avatar Feb 05 '21 05:02 khughitt

Hm, a paused entry would actually be two entries, one stopped at a certain time and a following one started at a later time. So basically you'd like to have a way to stop a running entry and then start a new tracker (on the same project/task) without having to manually specify all the details again, right?

What I could think of is an alias to finish that would be pause and a shortcut to track (including the last used options) that would be unpause.

mrusme avatar Feb 06 '21 04:02 mrusme

That's a good way to think about it.. Probably just need to be a little careful to capture/re-run the last track command, excluding things like "--begin" if they were specified.

khughitt avatar Feb 06 '21 20:02 khughitt

nothing to do with this issue and perhaps not the best place for this, as a result, but, i just wanted to let you know that I've been using zeit steadily for the past couple months or so, and found it to be really helpful.. thanks for sharing this :)

khughitt avatar Mar 10 '21 02:03 khughitt

@khughitt thank you, appreciate it, glad you enjoy it! Haven't had much time lately to push zeit forward, mostly due to it working for me, heh. However, a few updates are in the making. :)

mrusme avatar Mar 15 '21 04:03 mrusme

Heh. No worries! To be honest, it's been working great for me, so you aren't holding me up.

In case it helps, here are some aliases I defined to save a bit of time:

alias z='zeit'
alias zf='zeit finish'
alias zp='zeit track -p '
alias zl='zeit list'
alias zt='zeit tracking'
alias ze="zeit entry \`zeit --no-colors list | tail -1 | awk '{print \$1}'\`"
alias zrm="zeit erase \`zeit --no-colors list | tail -1 | awk '{print \$1}'\`"

I still need to get better about remembering to start/stop zeit sometimes (I tend to use --begin and --finish a bunch to make up for forgetting..), but even that is getting better with time.. I think it's just a matter of making it a habit.

khughitt avatar Mar 17 '21 22:03 khughitt

Hi @khughitt; I wrote the following alias that you may find handy:

function zbreak {
  date -v-$1M +%H:%M | xargs -I{} zeit finish -s {}
  zstart 
}

Example use case: you go for lunch/a walk/a nap for 28 minutes: Afterwards, you return to your Mac and type:

zbreak 28

This will pause the currently running task at the current time -28 minutes, and immediately restart it. This works for me as I only have one task. Not sure how it would work with multiple tasks.

harnoorsaini avatar Jul 29 '22 04:07 harnoorsaini

Thanks, @harnoorsaini !

Great idea. Here is a version that works for me on linux:

function zbreak {
  # get current task
  tracking=`zeit tracking --no-colors`
  task_=`echo $tracking | grep --color='never' -o "on [a-z0-9\-]* for" | sed "s/on //" | sed "s/ for//"`

  # stop
  zeit finish -s "-0:$1"

  # resume
  zeit track -p $task_
}

It should at least work for times <= 59 mins.

khughitt avatar Jul 29 '22 22:07 khughitt

@khughitt, oh sorry should have mentioned it's for macOS. And I have another of my aliases in there.

If you can pass "M" flag into date it should work for any number of minutes?

harnoorsaini avatar Jul 30 '22 01:07 harnoorsaini

@harnoorsaini No worries! You did mention you are on a Mac :)

Thanks for the suggestion!

khughitt avatar Jul 30 '22 05:07 khughitt