.bash_profile

kolax

macrumors G3
Original poster
Mar 20, 2007
9,186
115
I'm trying to set up my Terminal (bash) so that in history it doesn't show duplicate commands (i.e. if I type a command 5 times, then press the up arrow to go through the history it only shows it once).

There's no .bash_profile in my Home directory, so I created one, and added the following line:

export HISTCONTROL=ignoredups

However, still can't get it to work.
 
Last edited:

Mumford

macrumors regular
Oct 8, 2006
181
2
Altadena, CA
I'm trying to set up my Terminal (bash) so that in history it doesn't show duplicate commands (i.e. if I type a command 5 times, then press the up arrow to go through the history it only shows it once).

There's no .bash_profile in my Home directory, so I created one, and added the following line:

export HISTCONTROL=erasedups

However, still can't get it to work.
.bash_profile is only loaded at login. You want to add it .bashrc which is loaded every time a new shell (terminal window) is started.

Or do what I do and link them to be the same file.
 

kolax

macrumors G3
Original poster
Mar 20, 2007
9,186
115
I had to create .bashrc too, added the line, but still doesn't work.
 

Mumford

macrumors regular
Oct 8, 2006
181
2
Altadena, CA
Did you start a new terminal? Changes to .bashrc won't take effect in an existing terminal. If you type env | grep HISTCONTROL in this new terminal, what's the output?
 

kolax

macrumors G3
Original poster
Mar 20, 2007
9,186
115
Yeah, quit and re-opened it. I created .bashrc and env | grep HISTCONTROL outputs nothing. Renamed it to .profile and env | grep HISTCONTROL outputs HISTCONTROL=ignoredups.

However, it still doesn't work. :confused:
 

kolax

macrumors G3
Original poster
Mar 20, 2007
9,186
115
Haha, it does work.

I just didn't test it properly - I was scrolling up through my history and seeing duplicates, but I didn't realise it would only impact new bits of history, not ones that existed before I changed the settings.