Open Mail Attachment with Unix-standard programs I use emacs as my standard text editor.  When someone sends me a mail attachment that contains text (for example a LaTeX file *.tex), Mail does not know how to open it and asks me to select an Application for opening.  A Finder window pops up listing all the Applications installed, some of which are text editors, e.g. TextEdit.

The emacs program lives in /usr/bin/emacs, but the /usr directory is not visible by default in Finder.  After some Google searching, I found that executing a

sudo chflags nohidden /usr


will make the /usr directory visible in Finder.  I can then navigate to /usr/bin and see emacs in that directory, but it is grey'ed out and not selectable.

How do I select a non-Applications (i.e. /usr/bin/emacs, /usr/bin/vim, /usr/bin/gs, etc.) program to use for opening Mail attachments?
You cannot as the process is controlled by LaunchServices

When an application e.g. Mail.app wants to open a document it launches (or relaunches) the application that reads it and sends information to the document by Apple Events as described in Open Operations

thus the handlers have to recognise these Apple Events which are managed by the Cocoa or Carbon libraries.

So to use emacs, vi etc you need to use one wrapped up as an app e.g. Aquamacs, Cocoa or Carbon version of emacs, MacVim etc.

Another way of thinking about this is if there is no terminal open how woul the Unix command write to the GUI?