.bash_profile

Discussion in 'OS X Mountain Lion (10.8)' started by Kilamite, Aug 8, 2012.

  1. Kilamite, Aug 8, 2012
    Last edited: Aug 8, 2012

    macrumors G3

    Kilamite

    Joined:
    Mar 20, 2007
    #1
    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.
     
  2. macrumors regular

    Joined:
    Oct 8, 2006
    Location:
    Altadena, CA
    #2
    .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.
     
  3. thread starter macrumors G3

    Kilamite

    Joined:
    Mar 20, 2007
    #3
    I had to create .bashrc too, added the line, but still doesn't work.
     
  4. macrumors regular

    Joined:
    Oct 8, 2006
    Location:
    Altadena, CA
    #4
    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?
     
  5. thread starter macrumors G3

    Kilamite

    Joined:
    Mar 20, 2007
    #5
    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:
     
  6. thread starter macrumors G3

    Kilamite

    Joined:
    Mar 20, 2007
    #6
    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.
     

Share This Page