Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Forquare1

macrumors newbie
Original poster
Jun 22, 2008
20
0
Hi all,

I'm on Leopard, latest update. I'm trying to set up vi mode in my .bashrc:
Code:
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?

Thanks,

Ben
 
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:

Code:
vi .bashrc
 
Thanks pjrobertson

But I want to set vi mode, if you open your Terminal, then type:
Code:
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...

Ben
 
Fixed! :D

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

Instead you have to place:
Code:
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...
 
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

Code:
source ~./bashrc

to your .bash_profile will cause login shells to read .bashrc.
 
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.

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 :)
 
Fixed! :D

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

Instead you have to place:
Code:
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...

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

Code:
# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

This is what I put in my .bash_profile when I started using OS X and it worked perfectly.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.