5

How do I set Sublime Text as the editor for git commits in Mac OS X?

In my .zshrc I have:

export EDITOR='subl -w'

But, if I do:

bundle open devise

I get the error:

Could not run 'subl -w /Users/edwardandrews-hodgson/.rvm/gems/ruby-1.9.2-p320@neighbours/gems/devise-2.1.3'

How should I reference Sublime?

MattDMo
  • 5,309
  • 24
  • 30
Edward
  • 153
  • 1
  • 5
  • 1
    Can you launch Sublime Text by running `subl -w` manually? –  Jun 19 '13 at 15:11
  • if the subl executable is not in your path, try using the full path in the editor environment variable –  Jun 19 '13 at 15:20
  • ...or add the path to where the `subl` command is living. – TTM Jun 19 '13 at 16:10

1 Answers1

6

First, you'll need to create a soft link to the subl command. If you haven't already, create a personal bin directory:

mkdir ~/bin

then create the soft link:

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

Next, open your .zshrc and add the following to the end:

export PATH=$PATH:~/bin

Now restart Terminal.app (or whichever term program you're using) and you should be able to open any file in ST2 from the command line using the subl command. Since your $EDITOR variable is already set properly, bundle open devise should work as expected. Keep in mind that if you have the MacPorts version of Python installed, you'll need to open Sublime Text 2.app from the Finder before the command line subl command will work.

MattDMo
  • 5,309
  • 24
  • 30