Improving your quality of life as a developer

27 Oct 2023 12:53

I’ve just come off a call with a colleague and while he was sharing his screen and we were walking through some things, I noticed that his setup is missing all of the little “quality of life” tweaks that I’ve made over the years.

Tab Completion

As Scott Hanselman says:

There are a finite number of keystrokes left in your hands before you die.

He’s talking about a different topic, but it still applies here. Every time you have to type out the full name of a file, that’s wasted keystrokes which you could be using for something better.

So: enable tab completion in your shell of choice. Enable it for everything. I’m currently using Zsh with Oh My Zsh, and I’ve got tab completion enabled for git, for kubectl, for docker and for many other commands that I use daily or hourly.

You knew that you can press the Up key to recall previous commands already.

But did you know that you can press Ctrl+R to search those previous commands?

You want to run docker compose up? Well, you could type it in from scratch, again, or you could press Up half a dozen times, or you could press Ctrl+R, type up and then press Enter. Much quicker. Fewer typos.

A related tip for this is Ned Batcheler’s bashtags.

Prettify your prompt

You’re not just doing this because it looks cool. You’re doing it because you’re typing git status fifty times a day because you forgot which branch you were working on. Get a nicer prompt.

As mentioned, I’m using Oh My Zsh, which provides themes. Check them out. Edit one of those to suit your preferences. Write your own. Mine is here. Other shells provide similar functionality.

You could even check out Starship which provides a customizable cross-shell prompt. I didn’t get on with it, but it’s your prompt. Do whatever you want with it.

Shell Aliases

I’m not a huge fan of shell aliases (I lean on tab completion), but another one of my colleagues loves them.

He uses them for jumping to different directories (need to get to the CI pipeline for the QA environment? just type qa).

The various Oh My Zsh plugins add extra ones (need a list of Kubernetes pods? Just type kgpo – or something; I disabled the aliases).

Git Aliases

What I do have, is several useful aliases for Git. For example, git st gives me a shortened version of git status which displays just the information I need to know. git ci is git commit, but it also displays the diff right there in the editor, so that I can jog my memory about what I changed.

Here’s the relevant snippet from my ~/.gitconfig:

    st = status --short --branch
    ci = commit --verbose
    br = branch --sort=-committerdate

Learn your $EDITOR properly

Learn how to use your editor properly. Install a bunch of plugins to improve your quality of life. If you’re using vim, learn some of the basic keystrokes. You’ll save so much more time, and you’ll look like a genius to your mouse-using colleagues.