Mac – trying to run FSF emacs in character based mode ( -nw ) on Catalina

aliasbashemacsterminal

After installing Catalina on my laptop emacs vanished so I installed the latest version from FSF. Running it in a window (gui mode) works fine but I can't get it to reliably work in character mode in Terminal.

I can run it fine like this

/Applications/Emacs.app/Contents/MacOS/Emacs -nw

but when I try and create an alias I get an unhelpful error:

alias emacs='/Applications/Emacs.app/Contents/MacOS/Emacs -nw  $1'
emacs
LSOpenURLsWithRole() failed for the application /Applications/Emacs.app with error -10810.

I found references to starting emacs using open in an alias but open keeps grabbing the -nw and if I use the –args to pass -nw to emacs I get the same error 10810 as above

Best Answer

I actually solved this before I posted but decided that it is worth documenting what I found out.

It turns out that /Applications/Emacs.app/Contents/MacOS/Emacs is a small ruby script that figures out which binary to run (there are three):

ls -l /Applications/Emacs.app/Contents/MacOS/
total 110296

-rwxr-xr-x@  1 rful011  admin      3408  2 Sep 19:19 Emacs
-rwxr-xr-x@  1 rful011  admin  18889792  2 Sep 19:19 Emacs-x86_64-10_10
-rwxr-xr-x@  1 rful011  admin  18690016  2 Sep 19:19 Emacs-x86_64-10_14
-rwxr-xr-x@  1 rful011  admin  18883904  2 Sep 19:19 Emacs-x86_64-10_9

and if I make my alias

alias emacs='/Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_14 -nw $1'

it works.

Related Question