Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed emacs on my MacBook Air running Mac OS X 10.6.5 from this site I believe this is what used to be called cocoa emacs. I dragged it into my Application folder and it works fine when I run it from there. I want to be able to run it from the Terminal. After some googling, I tried open -a /Application/ foo.txt (foo.txt was and existing file). I got two emacs windows - one with welcome screen and one with foo.txt loaded. I tried a few applications in the /Applications directory and they did not seem to behave like this. I had installed it using my own account (an admin account) so after doing ls -l on /Application I noticed that the owner and group were different from the other entries in this folder. I recursively changed the owner and group to root and wheel, like the others, but this did not help. The only thing that looks funny now is that there that ls -l show a @ character which has something to do with extended attributes but I don't know how to check these.

Any suggestions on what to check next?

Is using the open command the only to run the program? Can I simulate what it does using a shell script?

share|improve this question

migrated from Feb 6 '11 at 1:41

This question came from our site for system and network administrators.

do you want emacs to load /in/ the Terminal window? Or do you want it to spawn window like you described? I figure, if you're in Terminal, you might just want to run emacs in Terminal, but I could be wrong. Asmus' suggestion would work if you want the former. – Avery Chan May 19 '12 at 9:21

You misunderstand how open works: With your command open /Application/ foo.txt you tell open to open two files, namely Emacs and the txt file, but these are two different operations: First, emacs will be started, and then foo.txt will be loaded with the default program for .txt files, which is apparently Emacs in your case.

As long as Emacs is the default for this file type, just using open foo.txt would open the file in Emacs, but if it is not the default, you would have to use open foo.txt -a /Applications/ (the -a switch tells open what application to use) or maybe you could hand it over as a parameter with the --args option like this: open /Applications/ --args foo.txt.

share|improve this answer
He is using the -a switch. – Daniel Beck Feb 6 '11 at 8:03

This actually is a bit strange; for my installation (which I did with homebrew), open -a Emacs file.txt works fine… maybe you should rebuild your LaunchServices database? But anyway, you should be able to call the executable directly with

/Applications/ file.txt
share|improve this answer

You must log in to answer this question.

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