How to start “emacsformacosx” in terminal

前端 未结 5 1887
北海茫月
北海茫月 2020-12-29 04:02

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<

相关标签:
5条回答
  • 2020-12-29 04:20

    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")

    0 讨论(0)
  • 2020-12-29 04:24

    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)

    0 讨论(0)
  • 2020-12-29 04:29

    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))
    
    0 讨论(0)
  • 2020-12-29 04:29

    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

    0 讨论(0)
  • 2020-12-29 04:36

    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

    0 讨论(0)
提交回复
热议问题