How to Track Your Engineering Work

4 points by codazoda 2 days ago

There are lots of reasons you might track your work. Maybe you do an annual performance review. Maybe you want to post status updates online. In my case, I want to create a monthly mailing list and let people know what I've been up to lately.

But, right now, I'm not keeping great track of my work.

I spend much of my day on the command-line and I typically enjoy command-line tools, so lets fix that with a quick bash script.

## How I want it to work

The syntax I ultimately want to use is something like the following:

    log "Something I did today"

## Echoing to a file

At first, I'm going to keep this extremely simple. I'll append the string to a file. The command to do that would be something like this:

    echo "Something I did today" >> ~/monthly.log
To break this down:

- echo prints the argument you pass it

- >> means to redirect that to the end of a file, appending to it

- ~/monthly.log means the log file in my home (~) directory

## Creating a shorter alias

Because I want a shorter command, just the word `log` followed by my comments, I'm going to put this into my `~/.zshrc` file as an alias. I use a Mac and have my terminal set to the default zsh shell. Something similar should work in Linux and maybe even Windows Subsystem for Linux (WSL). Here's the alias I'll use:

    alias log="echo $1 >> ~/monthly.log"
This sets up an alias with the name of `log` that runs the echo command outlined above. You'll notice that I added `$1` this time. That's a variable that brings in the first argument after your command. So, I can now use the following command:

    log "Something I did today"
The result will be a `monthly.log` file in my home directory with that line added to it.

## Reducing future maintenance

That's great, and I could stop there, but it will be a little bit manual right now. Every month I would need to rename that file. Instead, I want it to write to a file named after the month automatically.

One way I could do that is by running the `date` command. Here's a command that outputs the date in the format `YYYY-dd`.

    date +%Y-%m
I can use backticks to run the date command and return its value into the alias above. Here's how my alias will look after I update it to do that.

    alias log="echo $1 >> ~/log/`date +%Y-%m`.log"
This will echo the first argument ($1) to a file named `~/log/2024-10.log` when you run it in October. There is no longer a need to do any updates manually. Your log will be stored in the `~/log` directory as a series of files named after the current month and year.

We've added a `log` directory to the path but that directory needs to exist before we can write to it. For now, I'll create the directory manually with the following command:

    mkdir ~/log

## Using a function instead of an alias

If you make your own logging command more complex, you're probably getting to the point where you should write a function instead of an alias. Here's an example of this updated to a function:

    function log() {
        if [[ -z "$1" ]]; then
            echo "Usage: log \"<message>\""
            return 1
        fi
        echo "- $1" >> ~/log/`date +%Y-%m`.log
    }

## Happy logging

That's it. Happy logging!

In an upcoming post I'll figure out how to send this log as an email to a small number of subscribers.

Note: I'm not sure if I'm allowed to post a little how-to like this on HN. I don't think it's specifically disallowed in the rules but I'm not sure I've seen a lot of it either. Let me know if you think this doesn't belong here.

etcd 25 minutes ago

I think this is a human habit issue not a tech one. You could use vim, emacs, vscode, notepad++, confluence, onenote, notion, notes app, email yourself, google docs, google sheets, microsoft todo, google calendar etc.

But you need a brain system to motivate you to do it. Which means knowing why you want to do it but also getting into habits. And repicking uo the habit time and time again after it gets dropped because life happened.

You have provided some nice kettlebells, but one still needs to go to the gym regularly to use them!

al_borland 2 days ago

I had to track everything I did for a while, then fill out weekly reports that were due monthly. I ended up writing something similar, where it would log everything to a single file with a timestamp. I then had some commands that would let me pull back the previous day, previous n days, or any specified date range.

Eventually I changed this up and made something that I could trigger with a keyboard shortcut, would pull up a prompt, and append it to a daily note I had in Obsidian.

I don't have to track things as much anymore and I noticed I became a lot more productive and a bit more happy when I wasn't worried about accounting for every minute of my work day.

  • codazoda 2 days ago

    I’ve been using Obsidian lately. I’m curious to know more about what you did to pull up a prompt. That could be a slick change.

    I also tried to do this for work, not because I was required to but because I was curious, and I also found it exhausting. Maybe logging only the main things would feel better.

    • al_borland 2 days ago

      I’ve done the text prompt a couple different ways.

      One was with HammerSpoon. The config is in Lua. I could bind a function to a keyboard shortcut, have it bring up a text field, and append the input to my file based on getting the current date.

      I also did something similar with AppleScript (which actually uses some JavaScript now) and used the native features of macOS to setup a keyboard shortcut. If I remember correctly this required some nonsense with Automator (maybe Shortcuts would be the way to go now). All of this was done because I was having some weird behaviors and wanted to get rid of HammerSpoon to reduce possible causes. HammerSpoon didn’t seem to be the problem.

      Previously when I was on Windows I’d use AutoHotKey for this kind of thing.

codingdave 2 days ago

> Let me know if you think this doesn't belong here.

Well, you asked, so... :)

No, posts like this are not disallowed, but neither is it the main goal of the site. Self-promotion is allowed... if it is a minor component of your contributions to the site. You do contribute to the site, so that would not be a problem. I'd recommend you just put up a blog, and post an occasional link to an off-HN post. When you do post here, don't copy/paste markdown. It doesn't render and makes the whole thing harder to read.

Personally, I dislike these types of posts, but I'm just one guy. There are probably a variety of opinions on the matter.

youio 2 days ago

have you tried taskwarrior?