.bashrc doesn't work?

Discussion in 'macOS' started by Forquare1, Sep 7, 2008.

  1. Forquare1 macrumors newbie

    Jun 22, 2008
    Hi all,

    I'm on Leopard, latest update. I'm trying to set up vi mode in my .bashrc:
    set -o vi
    The file was originally called .bash_rc and it didn't work then, so I named it .bashrc and it still doesn't work...

    Any ideas?


  2. pjrobertson macrumors 6502a

    Nov 14, 2007
    Not sure what you mean.

    If you just want to open .bashrc with vi (vi is a program, it's like a textedit, but just in the terminal)

    just cd to the right folder: ~/

    then type:

    vi .bashrc
  3. Forquare1 thread starter macrumors newbie

    Jun 22, 2008
    Thanks pjrobertson

    But I want to set vi mode, if you open your Terminal, then type:
    set -o vi
    Then you can type you commands, then hit escape and skip words (B/E), press 0 to zoom to the beginning of the line, $ to wizz to the end dd to delete the whole command even...

    To resume typing your command, you then use i or a depending on what you need to do...
    I think the default is emacs command line, and since I know vi, I might as well use those commands for jumping words, rather than learning a different way :p

    The problem is that when I punch that line into my ~/.bashrc and start a new terminal, it doesn't seem to use vi mode :( So somewhere aliong the line, it doesn't appear to be reading my ~/.bashrc
    I've done this in Solaris and it works fine by the way...

  4. Forquare1 thread starter macrumors newbie

    Jun 22, 2008
    Fixed! :D

    Apparently OS X doesn't automatically look in your .bashrc file :mad:

    Instead you have to place:
    source $HOME/.bashrc
    into your .profile, then it is included...

    Weird as other systems don't seem to do this...Or if they do it's all set up for you...
  5. AquaMethod macrumors member

    Jun 17, 2008
    When you open a Terminal window, you're creating an interactive login shell. Login shells don't read ~/.bashrc; they read ~/.bash_profile

    If you create a non-login shell (such as typing bash to launch a new shell), that'll read .bashrc and inherit those vi settings. Like you said, adding

    source ~./bashrc
    to your .bash_profile will cause login shells to read .bashrc.
  6. Forquare1 thread starter macrumors newbie

    Jun 22, 2008
    I know that this should have, but after quitting and opening Terminal, it didn't work, after typing 'bash' it didn't work...I even did a system restart, didn't think it would help, and it didn't :(

    Seems to work now though :)
  7. MacUser2525 macrumors 68000


    Mar 17, 2007
    Well on Debian I had to remove the comment out (#) from these lines in the .bash_profile for it to work.

    # include .bashrc if it exists
    if [ -f ~/.bashrc ]; then
        . ~/.bashrc
    This is what I put in my .bash_profile when I started using OS X and it worked perfectly.

Share This Page