Drazen Bebic
Posted on September 18, 2024
Like many other developers I work for a software agency. We sell development hours for money. Pretty straightforward. To know how much we have to bill to which one of our customers we use time-tracking software. And let's be honest—keeping track of time can sometimes feel like the hardest part of the job. So, I built a little tool to make this chore a bit easier.
I am lazy
In an ideal world where developers aren't lazy and the beer flows freely I would keep track of the time spent on my tasks as I work on said task. But since we don't live in an ideal world, and I am a lazy developer, I find myself often in the position of toggling the entire week (or longer) on a Friday.
Ever found yourself at the end of the week wondering what you even did? Yeah, me too.
But I am a developer, too
As you can see, this was starting to become a problem because: Who the hell knows what they did 4 days ago, right? Well I found a solution to the problem: wdid
wdid
stands for "What did I do?" and is a simple bash script which I added to my .zshrc
file. This little script has saved me countless times. It's dead simple—just a function that fetches my Git logs by date. Here's what it looks like:
function wdid() {
local USERDATE=$1;
if [ -z "$USERDATE" ]; then
git log --all --author="$(git config user.name)" --pretty=format:'(%cs) - %s'
return;
fi
if [[ "$USERDATE" == "today" ]]; then
USERDATE=$(date '+%Y-%m-%d')
fi
git log --all --author="$(git config user.name)" --pretty=format:'(%cs) - %s' --after="$USERDATE 00:00" --before="$USERDATE 23:59"
return;
}
With this script, I can easily print out the Git logs of a specific date for the repository I'm currently in. For example, if today was Friday, the 13th of September 2024, and I needed to know what I did on Monday of that week (the 9th of September), I would simply do this:
wdid 2024-09-09
The output would look something like this:
(2024-09-13) - fix(TICKET-01): add pre-commit hooks
(2024-09-13) - fix(TICKET-05): update dependencies
Nifty, right? Since we use the ticket numbers in our commits it makes this whole thing very easy to follow. You can also do wdid today
to get today's Git logs, but I haven't used that yet, to be honest. My memory isn't that bad... yet.
You can hold a job?
I know. Why don't I just keep track of the hours as I work on them, you ask? Well, I try to do that too, but too often, I'm overly focused on the task at hand and can't be bothered with clocking in the hours right away.
Instead of stressing out every Friday trying to remember the details of my week, wdid
gives me a clear snapshot of what I’ve done. It’s simple, fast, and takes the guesswork out of time-tracking.
I’m trying to improve on the whole "track your time as you go" thing, and I am making some progress, but wdid
still saves my hide at least once a month.
Posted on September 18, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 26, 2024