Quick tip for better UNIX history

2022-10-15 Linux Mac

The history command is one that I use all the time. Whether your history lives in .zsh_history or in .bash_history, it is the database for Cmd+R, for the up and down arrow and other methods.

I’ve got a small tip for a more legible history when you run that command on Mac on Linux. It is simply about adding a comment to your line, like this:

git log -g master | grep ^commit # Show reflog of master

Treating your history with can pay dividend. And keeping it clean does help. You can always delete the lines in history that do not give you value.

history -d <line>

Also keep in mind that deleting the history is as simple as history -c, so avoid treating it like a forever document.