Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm trying to migrate to OS X. One thing what I find really strange / dangerous that by double clicking on shell scripts, I launch them in Terminal.

I would like to change this behaviour to open them in Sublime Text.

My problem is that while I can do it to single files using the "Get Info" dialog, I cannot apply "Change All..." for these kind of files.

For other filetypes it worked OK, but for .sh / Unix Executable File I cannot assign them.

When I click, I get the following error dialog: The operation can't be completed. An unexpected error occurred (error code -50).

share|improve this question
    
I don't know why you are getting error code -50, I tried it on my system and it worked perfectly fine. Look at this post to use Terminal to do it: apple.stackexchange.com/a/91558/49601 –  Danijel J Feb 27 at 14:49
1  
Thanks, duti solved it! –  zsero Feb 27 at 15:39

1 Answer 1

up vote 1 down vote accepted

Install duti by running brew install duti, save a file like

com.apple.TextEdit public.unix-executable all

as ~/.duti, and then run /usr/local/bin/duti ~/.duti. After that executable scripts with no filename extension should be opened in TextEdit.

Another option is to run plutil -convert xml1 ~/Library/Preferences/com.apple.LaunchServices.plist, open the plist in a text editor, add an entry like

<dict>
  <key>LSHandlerContentType</key>
  <string>public.unix-executable</string>
  <key>LSHandlerRoleAll</key>
  <string>com.apple.TextEdit</string>
</dict>

under LSHandlers, and then restart to apply the changes.

The default application for shell scripts with a .sh extension can be changed from Finder:

share|improve this answer
    
Yes, that's the button which didn't work for me (error code -50). But duti works fine. –  zsero Feb 28 at 15:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.