PDA

View Full Version : .bash_profile




Kilamite
Aug 8, 2012, 10:22 AM
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.



Mumford
Aug 8, 2012, 10:27 AM
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.

Kilamite
Aug 8, 2012, 10:31 AM
I had to create .bashrc too, added the line, but still doesn't work.

Mumford
Aug 8, 2012, 10:55 AM
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?

Kilamite
Aug 8, 2012, 02:06 PM
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:

Kilamite
Aug 8, 2012, 03:12 PM
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.