How does Mountain Lion set the default text editor for the “open -t” terminal command

command linetext-editortextedit

OSX seem to offer open -t command line shortcut to open arbitrary files in the system default text editor.

  • Where is this default text editor set?

  • Can I change it from the command line (if possible) or otherwise programmatically?

The default choice of TextEdit is limiting.

Best Answer

It's the default application for plain text (public.plain-text) files. You can change it from Finder's information panels or with duti.

You can also edit ~/Library/Preferences/com.apple.launchservices.plist, but it requires restarting to apply the changes.

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

Related Question