Discussion:
Shell script to make BBEdit the default text editor for 'open -t' and LaunchServices
TJ Luoma
2018-07-25 14:41:24 UTC
Permalink
I was looking for a way to make BBEdit the default text editor for _all_
text files.

More specifically, I wanted to be able to use 'open -t' and have the file
open in BBEdit.

Just to refresh your memory, quoting from `man open`:

-t Causes the file to be opened with the default text editor, as
determined via LaunchServices

I went searching on the web for this, but 99% of what I saw came down to
"Select the file in Finder, choose 'Get Info' and tell it to 'Change All'
of those file extension types to open with BBEdit!' Of course that wasn't
helpful because I already knew that, but what about files with _no_
extension? And what about 'open -t'?

Finally I came across a StackOverflow answer
(https://stackoverflow.com/questions/9370584/set-textmate-as-the-default-text-editor-on-mac-os-x)
which gave me enough of an answer that I was able to adapt it for BBEdit.

In case anyone else is curious, here is the command that I used:

defaults write com.apple.LaunchServices/com.apple.launchservices.secure
LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.barebones.bbedit;}'


After that, I used `open -t ~/.ssh/authorized_keys` and the file opened in
BBEdit. I didn't even have to logout/login or reboot, as some had suggested.

(This was in the public beta 3 of Mojave, FWIW.)

I hope this might be of use to someone else
 or possibly me, in the future,
when I search the web for the answer to this question and find my own
answer to it ;-)

Tj
--
This is the BBEdit Talk public discussion group. If you have a
feature request or would like to report a problem, please email
"***@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.
@lbutlr
2018-07-25 20:30:55 UTC
Permalink
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.barebones.bbedit;}'
It does not appear to work in beta 4.
--
This is the BBEdit Talk public discussion group. If you have a
feature request or would like to report a problem, please email
"***@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.
Bruce Van Allen
2018-07-25 21:37:15 UTC
Permalink
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.barebones.bbedit;}'
It does not appear to work in beta 4.
Just checking: you might need to log out and back in again.
--
- Bruce

_bruce__van_allen__santa_cruz__ca_
--
This is the BBEdit Talk public discussion group. If you have a
feature request or would like to report a problem, please email
"***@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.
Loading...