I'd like for the mac os terminal app to scroll through my command history the same way that it work in linux, if possible. Currently, if I push the up arrow in the terminal, it will scroll through each and every one of my recent commands even if the last 50 were the same exact command. On most linux systems I've used, this behavior will scroll backwards through command history, but most importanlty it will skip duplicate commands. Is this behavior possible in Mac OS X terminal app, or do I need to use a different terminal app? Thanks.
2 Answers
Mark who commented on my questions above was correct. This is a bash setting. If you add the following to your ~/.bashrc
script, you will get this behavior.
HISTCONTROL=ignoredups
You can also ignore any lines that start with a space:
HISTCONTROL=ignorespace
Or do both, by using:
HISTCONTROL=ignoreboth
-
3Strictly better add to .bashrc and make .bash_profile source .bashrc - see bash manual– mmmmmmOct 23, 2015 at 19:14
Assuming that you are using bash then
HISTCONTROL=ignoreboth
or
HISTCONTROL=ignoreboth:erasedups
in one of your bash rc file(s).