sb2nov / mac-setup

Installing Development environment on macOS

Home Page:https://sourabhbajaj.com/mac-setup/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sublime as default text editor

oberrauch opened this issue · comments

I'm Submitting a ...

[ ] Bug report
[x] Tool/language/etc documentation request

Tool/Language/etc

I think it is handy to set Sublime Text as default text editor, in order to open any plain text file in Sublime via the command open -t foo.txt.
This is pretty easily done, by changing the Apples default launch service
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'
(for Sublime Text 3).
So maybe you want to include this into your guide...

I did not come up with this, all credits to John Staff at Coderwall and grg and Andrea Bergonzo at StackExchange.

Other Information

P.S.: Great job with this guide, and many thanks!

Hmm, I just use subl file.txt or code file.txt.

Yeah, sure. I just got used to it and so I though it would be an useful addition. People can than decide for them selfs, but at least it is noted and they don't have to search for it somewhere else.

I don't think we should assume people use Sublime. Me for example have never used it. I think it's better to mention how to open sublime using via the terminal, like @Kyslik shows, and if you want to have open as subl you can just have an alias for it, no need to change anything in the OS.

alias open="subl"

+1 to directly using subl when you need.

FYI just be careful if you alias open to subl as open currently works on all filetypes and this would limit it to only things that work with sublime.