Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Delete empty entries from timewarrior
# Delete timewarrior entries that are less than a minute long.
# Beware - in this version, grep doesn't check the duration field here, so if you have a task that starts at 0:00, that'll be delete too!
for i in $(timew summary :ids | grep '0:00:..' | awk '{print $1}' | tr '\n' ' '); do timew delete $i; donefor i in $(timew summary :ids | grep 0:00:00 | awk '{print $1}' | tr '\n' ' '); do timew delete $i; done
# This one extracts the id and duration fields and then does the bit, so it's safer, but it's more complex.
# The last grep decides what must be deleted, so one can change the regex there as one wishes.
for entry in $(timew summary :ids | grep -o '@.*' | sed -E 's/(^@[[:digit:]]+)([[:alpha:]|[:punct:]|[:space:]]+)/\1 /' | sed -E 's/[[:space:]]{2,}/ /' | cut -d ' ' -f 1,4 | grep -E '[[:digit:]]{0,2}:0[01]:..' | cut -d ' ' -f 1 | tr '\n' ' '); do timew delete $entry; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment