Can I run the bundle open command inside of MacVim? - ruby

When I issue the bundle open command in the terminal, the "vi" editor comes up, but it doesn't seem to have all the defaults and settings I'm used to, and it looks fairly ugly as well. Is there a way to have bundle open start-up in MacVim outside the terminal, or can I issue bundle open in MacVim so it comes up there?

You can have bundle open send the file to MacVim for you. First, you need to make sure the mvim script that comes with MacVim is installed; instructions here.
Then, as #Randy Morris said in a comment, you need to set your EDITOR environment variable to mvim. You could add that to your .bash_profile file in your home directory to make it permanent; pretty much every Unix command that launches an editor will use it.

Related

Use RVM Ruby instead of MAMP Ruby

I've used RVM to install the latest stable version of Ruby, however, I can't set it to be the default version. Running which ruby always returns the path of Ruby installed with MAMP on my system eg /Applications/MAMP/Library/bin/ruby
I've tried various rvm commands with no effect. I'd rather not have to run an rvm use command every time I open my terminal.
I'm using oh-my-zsh and iTerm2 if it makes a difference.
As Dave Newton suggested, this smells like a PATH issue, but in the case of MAMP, it's also an alias issue.
If you open ~/.profile and ~/.zprofile, in one of them you will probably see these lines:
alias erb='/Applications/MAMP/Library/bin/erb'
alias gem='/Applications/MAMP/Library/bin/gem'
alias irb='/Applications/MAMP/Library/bin/irb'
alias rake='/Applications/MAMP/Library/bin/rake'
alias rdoc='/Applications/MAMP/Library/bin/rdoc'
alias ri='/Applications/MAMP/Library/bin/ri'
alias ruby='/Applications/MAMP/Library/bin/ruby'
alias rails='/Applications/MAMP/Library/bin/rails'
You'll want to remove them all, save the file, then quit and restart iTerm2.
If you don't know how to open and edit dotfiles, read my guide that explains various ways to read and edit dotfiles on a Mac.
If removing those aliases doesn't fix it, then it's a PATH issue.
For your Mac to know about a command or other executable program, it has to be told where to look for it. It wouldn't be efficient for the computer to search the entire hard drive for the program.
Instead, it looks in a specific list of locations, which are stored in an environment variable called PATH, separated by a colon. You can view this list by running this command in your terminal:
echo $PATH
When you install new programs, such as Ruby, they might get installed in a location that is not already included in the PATH. If you don't add this new location to the PATH, the computer won't know to look for it there, and so it thinks it doesn't exist.
Similarly, if the location of the new program did get added to the PATH, but you have another location for the same program earlier in the PATH, then it will always use the first one it finds.
Most Ruby version managers use a script to automatically update the PATH, and they instruct you to add a line to your shell file to call that script, or they might add it for you. That line should come after any modifications of PATH.
It's been a while since I've used RVM (I no longer recommend it), but I think it's supposed to automatically add this line to your shell file:
source $HOME/.rvm/scripts/rvm
Assuming you installed RVM properly, here's what I would try:
Open your shell file. It should be ~/.zshrc if you're using oh-my-zsh.
Look for any lines that start with export PATH=, and if they mention /Applications/MAMP/Library/bin/ruby, remove that directory from the PATH. Also make sure any PATH lines come before the lines added by RVM.
Quit and restart iTerm2
If you don't see any RVM-related lines in ~/.zshrc or ~/.zprofile or ~/.profile, then RVM was not properly installed.
If you really want to use RVM, try uninstalling and reinstalling it. If all you care about is having a working Ruby environment, I would recommend chruby and ruby-install. You can install them by following my step-by-step guide to install Ruby on Mac.

How to use macvim (mvim) in terminal after install with homebrew

I installed macvim with homebrew and when i tip "mvim file" in terminal open the file in another window. Can I fix and open mvim in terminal?
The binary is needed by some plugins (YouCompleteMe), for one.
You can use the binary that is installed with macvim. By default, it's
/usr/local/Cellar/macvim/8.0-144_3/MacVim.app/Contents/MacOS/Vim
You can simply alias vim to it in your shell config (.bashrc, .zshrc, etc.)
alias vim=/usr/local/Cellar/macvim/8.0-144_3/MacVim.app/Contents/MacOS/Vim
MacVim (mvim) is not a terminal application. If you want to open vim in a terminal, just use "vim" instead.
We want the contents of the MacVim.app package to be in the PATH, but do this cleanly. So here's what I do:
cd /Applications; ln -s ../usr/local/Cellar/macvim/8.1-151_1/MacVim.app
That gets you MacVim in /Applications, via a symlink that can be updated when the package is upgraded. Then add this to the PATH in the shell startup file:
PATH=/Applications/MacVim.app/Contents/bin:$PATH
Then when you upgrade you just change the symlink in /Applications and everything still works nicely.

updating osx terminal after macport installation

I installed macports on my macbook pro and after the successful install, I tried typing in 'port' in a terminal tab that I had was already opened before the macport installation and it gave me the error "command not found"
When I opened another tab in the terminal and tried again, it worked. (It works in the new tab but does not work in the old one)
I am guessing that this has to do with the fact that the first tab was opened before the the macport installation took place.
Just wanted to know how to refresh the terminal after I install something like macports.
PS: I know that I can open a new tab and continue working but am just curious how to do so.
General: You can use the reset command:
reset
For more information run:
man reset
MacPorts: The PATH variable is set by the postflight script to append the MacPorts executable paths to the default path:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
The location of this line depends on your shell, the installer may use .profile, .bash_login, .bash_profile, .tcshrc, or .cshrc.
If you want these changes to take effect in the current Terminal window, you either need to execute this command manually:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Or if you know which file contains the line above, you can source it. For example:
source ~/.profile

Homebrew version of vim won't open files

I installed vim via brew so I could have the latest version (7.4) and get syntax highlighting for Clojure. No big deal. Unfortunately, the brew version of vim seems to be broken on my system. I also aliased the vim command:
brew install vim # Install went successfully
alias vim=/usr/local/Cellar/7.4.052/bin/vim # Shouldn't be any problems here
When I open the brew version of vim, it fails to load any of my plugins (I use spf13) throwing a bunch of "Undefined variable" and "Invalid expression", etc errors for every plugin in my bundle directory; I just hit enter to continue. My .vimrc loads properly. When I open a file, it opens two tabs, both blank. One is a new file, the other is the file I tried to open, except there's nothing in it.
Potentially useful information: echo $VIM returns an empty line, while echo $ZSH returns /User/bsima/.dotfiles as expected.
Here are my dotfiles, but I don't think the problem lies in those configuration files.
Is this a known bug? Or is something wrong with my vim install?
I have no idea what's going on and I really miss my vim :( As good as Textmate is, I can't be without vim forever.
Edit: MacVim, installed via Homebrew, kinda works. It still opens 2 tabs on startup, but it does open files for editing and saves.
I found the problem: it was with my spf13 vim config. The following commands fixed the issue, in addition to double-checking that symlinks such as ~/.vim and ~/.vimrc were correct:
> which vim # This should output /usr/local/bin/vim since I'm using Homebrew
/usr/local/bin/vim
> cd ~/.spf13-vim-3
> ./bootstrap.sh # Basically re-installs spf13

Compiled vim from source on Mac OSX and getting 'shell returned 127' error?

On my Mac OSX 10.6 machine, I started to use MacVIM for vim. Then I noticed my terminal version was different to the MacVIM version (MacVIM was 7.3 and my terminal version 7.2)... I thought they used the same vim?
I need 7.3 for some of the features. So I set about wanting to update the terminal version. I basically cloned it using Mercurial (the perferred way according to the official site) and then did the usual to compile it. This did work and I now have 7.3 in my terminal. But, on some commands when exiting, I can this error:
/bin/bash: q: command not found
shell returned 127
Press ENTER or type command to continue
...I've tried my hardest to try and fix this problem, but trying to reinstall MacVIM, deleting the vim in my /usr/local/bin and compiling again and I just can't get rid of this annoying error.
Can anyone possibly help me? Am I doing this all wrong? ...most of the time I will be using MacVIM, but it'd be nice for me to have it in the Terminal - exactly how I'd have it on my Ubuntu servers.
Any help would be fantastic!
:!q is not :q!. This is probably not a bug.
The error message you're seeing is is most likely the result of accidentally typing :!q instead of :q!, which would be user error, not a bug. :!q shells out to run q, and your shell (bash) is not finding such a command and bails with 127. (For comparison, you might try :!true, :!false, :!vim %, to get a feel of this.)
There isn't really a “fix” for this, and ! is really useful for other purposes; maybe with more practice you'll make the typo less often. You could also try using ZQ instead of :q!; this has other disadvantages (a typo ZZ will instead save the file if it's edited, and ZQ specifically is a vim extension), but at least you see this error again.
The upshot here is basically check to make sure you typed in your commands right, I guess.
I'm not sure on the exact path, but somewhere a few folders deep into the Applications/MacVim.app folder is the vim executable that will also run in a terminal (Use the -g option to launch it in GUI mode).
You should be able to throw this in your .bashrc:
alias vim=/Applications/MacVim.app/Contents/MacOS/vim
This is the homebrew formula for vim. Try these settings for "configure" or just install homebrew and install vim from there.
system "./configure", "--prefix=#{prefix}",
"--mandir=#{man}",
"--enable-gui=no",
"--without-x",
"--disable-nls",
"--enable-multibyte",
"--with-tlib=ncurses",
"--enable-pythoninterp",
"--enable-rubyinterp",
"--with-features=huge"
system "make"
system "make install"

Resources