Misframe

Dec 27, 2016

Removing duplicates in Bash history

I have a habit of spamming commands when I get impatient. Like this:

 374  ssh -v [email protected]
 375  ssh -v [email protected]
 376  ssh -v [email protected]
 377  ssh -v [email protected]
 378  ssh -v [email protected]
...
 402  ssh -v [email protected]
 403  ssh -v [email protected]
 404  ssh -v [email protected]
 405  ssh -v [email protected]

By default, Bash on macOS doesn’t remove duplicates, so I have to skip through them when I use the ā†‘ key to go back through my history.

Fortunately, I can add one line to my ~/.profile to remove those duplicates.

export HISTCONTROL=ignoredups
Next read these:
Feb 4, 2022
Feb 4, 2022
Dec 26, 2016