2

As a developer I need to constantly be examining/editing the contents of text files, and opening them from Finder and the command line.

I would like to right click the file in finder, and have the menu option "Open with Sublime Text Editor" or at least TextEdit!

There even seems to be the option to do this at least with the default TextEdit in Mavericks:

System Preferences > Keyboard > Shortcuts > Services > Files&Folders > Open Selected Files in TextEdit

But if I check that, nothing happens! As opposed to "new terminal at folder" which DOES work.

Instead I:

right click on the file -> Open with -> Other -> "tex"-> (click TextEdit) -> check "Always open with..." -> Open

And...

'foo.bar can't be opened because it is from an unidentified developer.'

WHAT? All that work for nothing!

Instead I have to launch TextEdit, and open the file.

The command line is no fun either; using vim / emacs is horrible; I don't want any editor where I have to remember some obscure keyboard shortcut to even get back to my terminal prompt.

So how do I achieve a decent workflow as a developer?

2
  • 1
    I keep a copy of Text Edit in my Dock; then whenever I want to open a file in Text Edit, I drag its icon onto the Text Edit icon in the Dock.
    – GEdgar
    Commented Jan 15, 2014 at 20:29
  • All the answers seem to be workarounds and are overlooking the basic problem which is that TextEdit is being regarded as from an unidentified developer. Since it's built-to the OSX distribution surely it should be considered a trusted application?
    – Andy
    Commented Sep 24, 2014 at 16:36

4 Answers 4

3

The "foo.bar can't be opened because it is from an unidentified developer" error is because of Gatekeeper. You can disable Gatekeeper from System Preferences:

Selecting "Always Open With" from the "Open With > Other..." dialog only changes the default application for the selected files. You can change the default application for all files of a type from a Show Info window:

You can add a context menu item for opening files in TextEdit by creating a service like this with Automator:

If you have the Powerpack for Alfred 2, you can also create a workflow like this:

You can use duti to make TextEdit the default application for plain text files without an extension and executable scripts. Install Homebrew, run brew install duti, save

com.apple.TextEdit public.plain-text all
com.apple.TextEdit public.unix-executable all

as ~/.duti, and then run /usr/local/bin/duti ~/.duti.

1
  • Thank you, I used your automantion solution as base and inspiration, and made better one with keyboard shortcut working.
    – Arkemlar
    Commented Aug 9, 2022 at 19:01
1

When you right click on the file in the Finder and select 'Open With` you should get a long list of options on any text file that includes Sublime Text if it is installed.

If you don't then there is a problem with either the file type (does it say 'Plain Text' or 'Python script` or similar as the file type?) or the Launch Services database.

Try rebuilding the Launch Services database with this command :

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\ LaunchServices.framework/Versions/A/Support/\ lsregister -kill -r -domain local -domain user

from the command line. It might take a while. Then restart the Finder with killall Finder.

As for opening files from the command line most decent editors designed for programming have a command line tool, Sublime Text 2 included. See the documentation here for all the details on how to set it up.

0

This may be your problem:

http://osxdaily.com/2012/07/27/app-cant-be-opened-because-it-is-from-an-unidentified-developer/

P.S.: I am lazy and do not want to type so I have referred you to a page that already contains everything I would have typed.

1
  • After fixing the unidentified developer problem, you can do the right click on the file -> Open with -> Other -> "tex"-> (click TextEdit) -> check "Always open with..." -> Open and it should work properly Commented Jan 15, 2014 at 22:51
0

Make keyboard shortcut to open any file in TextEdit. This worked perfectly for me!

  1. Open Automator and create new document, select Quick action:

enter image description here

  1. Configure settings:

enter image description here

  1. Add an Action as shown below:

enter image description here

  1. Select TextEdit

enter image description here

  1. Before you save new automation go to System Preferences > Keyboard > Shortcuts > Services > Files&Folders > Open in TextEdit. Check out that bold title. This is the name of your automation. This shortcut name and your acutomation name must be the same. (I'm not sure about "Open in TextEdit" title since my OS uses other language, other users feel free to fix that.) This is how it looks like for me:

enter image description here

And the final Automation config looks like:

enter image description here

Now by pressing Command + .(dot) Finder will open selected file in TextEdit. Binaries too! Set your shortcut as you normally do in System Preferences.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .