$> sl dc gti!!1!

So, I spend 98% of my life in the command line. It’s super effective and a lot of fun. But typos happen… A lot.

I am well aware of external commands that annoy you when you type the wrong command:

Having a steam locomotive or some gti car running through the terminal is fun!

But there is the dc command - known as desk calculator. Preinstalled on most systems. This is unfortunate as it drops you into some prompt, interrupting what you intended to do in the first place.

So I have solved this problem little bit differently: I’ve decided to count how often I type something wrong.

Inside my shell rc I’ve put some functions similar to this:

_missed() {
    track="$HOME/.missed_$1"
    count=$(cat "$track" 2> /dev/null)
    printf "'%s' missed %d times!!1!\n" "$2" "$((count = count + 1))"
    printf "%d" "$count" > "$track"
}
dc() { _missed "dc" "cd"; cd "$@" || return; }
sl() { _missed "sl" "ls"; ls "$@"; }
gti() { _missed "gti" "git"; git "$@"; }

They should work on most shells, might need some adaptions for different implementations.

I should synchronize the ~/.missed_* files across all my machines to have the total failure rate available 😅

So long!