Last active
December 28, 2017 11:00
-
-
Save sanjayankur31/04e920b24779837e1cf6b25170751dac to your computer and use it in GitHub Desktop.
Delete empty entries from timewarrior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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