I'm trying to set my $EDITOR variable to be emacs with no window, so the command to call it would be emacs -nw. However if I set it like this:

export EDITOR="/Applications/Emacs.app/Contents/MacOS/Emacs -nw"

I get the following error

zsh: no such file or directory: /Applications/Emacs.app/Contents/MacOS/Emacs -n

  • Have you checked if the programs take environment variables of configuration files to set such switches? – vonbrand Jan 23 '13 at 18:59

I believe this doesn't work because the shell would try to open a binary with the space included in the file name, so Emacs -nw, and not open Emacs and then pass -nw as the options.

How about making $EDITOR a small (executable) script, e.g. in ~/bin/EDITOR?

/Applications/Emacs.app/Contents/MacOS/Emacs -nw -- "$@"

Then, simply add to your shell's configuration:

export EDITOR=~/bin/EDITOR

Now, EDITOR will call the script with the appropriate arguments, expanded in $@.


As explained here: zsh: Command not found (for $EDITOR) , zsh treats the expanded variable as a single word (that has space characters in it).

Possible solutions are:

  • run in bash which expands the spaces properly

  • Use the '=' modifier on parameter expansion: see Expansion in the zsh documentation and look for '${=spec}'

  • use eval when calling $EDITOR as in:

    eval $EDITOR file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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