Mac – Brew cask install emacs takes control of the emacs command line command

command lineemacshomebrewui

I'm currently using Homebrew to install both the command line version of Emacs and the GUI version of emacs, with the following commands:

brew install emacs
brew cask install emacs

When I first install the command line version, I can launch it via the command line with the command emacs <filename>, but after I install the GUI version, using that same command, it causes the GUI version to open. I would like the command line version to continue to open from the command line command. I posted this in the homebrew forum, but the only answer I was given was to check my shell config file. I'm on macOS Catalina, so I'm assuming .zshrc is the file, but this contains nothing relating to Emacs at all. Any suggestions for how to keep the GUI version from being launched from the command line command would be greatly appreciated.

Best Answer

You could create an alias in zsh that invokes emacs -nw whenever you write emacs. The -nw argument means to start emacs in "non-windowed" mode - i.e. a command line text interface.

You can create the alias by editing the .zshrc file you mention, and add the following line:

alias emacs="emacs -nw"