I don’t know why I didn’t learn that like 30 years ago, but when you want to prevent a command ending up in your shell history, make sure to add a white-space character before the command,

$ echo foo
foo
$ history | tail -2
 1501  echo foo
 1502  history | tail -2
$  echo bar # note the leading whitespace
bar
$ history | tail -2
 1501  echo foo
 1502  history | tail -2

Now I feel less dumb.

P.S. Thu 16 Jun 2022 12:49:59 PM CEST: A friend pointed out that I’ve been GNU’ed. Only seems to work in bash.