I am using MAC OX 10.6 , and install the emacs from here http://emacsformacosx.com/
I want to know how to start it in terminal, so my ecb can open current directory<
By default terminal will open /usr/bin/emacs on OS X. You can change this behavior by changing what the "emacs" command will do. Open up ~/.profile and type the following:
alias emacs=open /Applications/Emacs.app
The next time you open a prompt this change will be active. (or you can run "source ~/.profile")
In my ~/.profile
i have the following:
function emacs
{
if [ -e "$@" ]
then
command open -a emacs "${@}"
else
touch "$@"
command open -a emacs "${@}"
fi
}
(The reason for having a function is to make it also work when the specified file does not yet exist when emacs is started)
The answer from @Toymakerii is a good one, but you might also consider adding:
export PATH=/Applications/Emacs.app/Contents/MacOS/bin:$PATH
This way, you can use emacsclient
to open files in an already-running Emacs instance:
emacsclient -t SOMEFILE # Open SOMEFILE in a terminal frame
emacsclient -c SOMEFILE # Open SOMEFILE in a new graphical frame
Depending on your Emacs version, you might need to put the following in your ~/.emacs.d/init.el
(or ~/.emacs
, if you're old-fashioned):
(require 'server)
(unless (server-running-p)
(server-start))
The easiest is to simply do
open /Applications/Emacs.app --args foo
An alias would then be
alias emacs=open /Applications/Emacs.app --args "${@}"
or in csh/tcsh
alias emacs 'open /Applications/Emacs.app --args $1'
edit: this seems to need a full path to open the correct file... I don't know if this is a problem with Emacs.app or with tcsh
It is actually quite easy, just run it from terminal like this:
/Applications/Emacs.app/Contents/MacOS/Emacs -nw
the -nw option means to start emacs without the gui frame.
You can put the following in your shell (on my mac .zshenv) :
alias Emacs="/Applications/Emacs.app/Contents/MacOS/Emacs -nw"
Then I just have two commands:
Emacs
: for emacs version 24
emacs
: for the apple version of emacs
Of course you can just alias the Emacs.app to emacs, but this allows me to customize the two differently - for instance Emacs 24 allows me to use list-packages and so forth. emacs 22 ignores most of this, so I can always revert to a 'bare metal' emacs if need be. Your usage may vary, but if you don't remember the arguments to emacs you can find them by doing this:
emacs --help
Some interesting ones:
Emacs.app --fullscreen
Emacs.app --line-spacing
Emacs.app --vertical-scroll-bars
More info here : http://www.gnu.org/software/emacs/manual/html_node/emacs/Option-Index.html#Option-Index