How to open shell scripts in editor when double clicking on them
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

&lt;dict&gt;
  &lt;key&gt;LSHandlerContentType&lt;/key&gt;
  &lt;string&gt;public.unix-executable&lt;/string&gt;
  &lt;key&gt;LSHandlerRoleAll&lt;/key&gt;
  &lt;string&gt;com.apple.TextEdit&lt;/string&gt;
&lt;/dict&gt;


under LSHandlers, and then restart to apply the changes.

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