When using Mac OSX there are times when opening a file from the terminal into your favorite editor is necessary. This is accomplished by using the .profile file located in your home directory.

Open files into MacVim

Add the following to your .profile and use “vim filename” top open the file into the external editor

alias vim='/Applications/MacVim.app/Contents/MacOS/Vim -g -f '

Now when you want to edit files in your terminal use:

vim thefilename.txt

and your MacVim editor will pop open with all its happyness.

Open files in TextMate

To open files in TextMate, you have to create a link to the ‘mate’ program. This is easily done during the install, but sometimes I forget to do this. The next way that is pretty easy is to run the following in your shell prompt:

sudo ls /Applications/TextMate.app/Contents/Resources/mate /usr/bin/mate

Now you are able to open folders and files into Textmate from the terminal using these commands:

cd to/your/folder
mate .

or

cd to/your/folder
mate thefilename.txt
comments powered by Disqus