Set TextMate as the default text editor on Mac OS X

The method through Finder is not practical. If you're a developer, your files likely include .profile, .gitconfig, .bashrc, .bash_profile, .htdocs, etc.

The best way to do this is in Bash (for Sublime Text 3):

defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'

For other text editors, I assume you can replace 'com.sublimetext.3' with the proper string. You could probably Google for your text editor's name + "LSHandlerContentType=public.plain-text" to figure out what your app's string would be.

For me, this changed the defaults for both Finder, and

$ open ~/.bashrc

Just right (or control) click a file of the type you want to change and:

"Get Info" -> "Open with:" -> (Select TextMate) -> "Change All"


Have you modified your shell PATH environment variable to include ~/bin? That directory is usually not included in PATH by default on OS X. It might be simpler to create the symlink in /usr/local/bin which is usually included in PATH. Try:

echo $PATH