【问题标题】:How to start "emacsformacosx" in terminal如何在终端中启动“emacsformacosx”
【发布时间】:2012-02-27 07:45:35
【问题描述】:

我使用的是 MAC OX 10.6,并从这里安装 emacs http://emacsformacosx.com/

我想知道如何在终端启动它,这样我的 ecb 就可以打开当前目录

【问题讨论】:

    标签: macos emacs


    【解决方案1】:

    其实很简单,只要像这样从终端运行它:

    /Applications/Emacs.app/Contents/MacOS/Emacs -nw
    

    -nw 选项意味着在没有 gui 框架的情况下启动 emacs。

    您可以将以下内容放入您的 shell(在我的 mac .zshenv 上):

    alias Emacs="/Applications/Emacs.app/Contents/MacOS/Emacs -nw"
    

    那么我只有两个命令:

    Emacs:对于 emacs 版本 24

    emacs : 苹果版的emacs

    当然,您可以将 Emacs.app 别名为 emacs,但这允许我以不同方式自定义两者 - 例如 Emacs 24 允许我使用 list-packages 等等。 emacs 22 忽略了大部分内容,因此如果需要,我总是可以恢复为“裸机”emacs。您的用法可能会有所不同,但如果您不记得 emacs 的参数,您可以通过以下操作找到它们:

    emacs --help
    

    一些有趣的:

    Emacs.app --fullscreen
    Emacs.app --line-spacing
    Emacs.app --vertical-scroll-bars
    

    更多信息在这里:http://www.gnu.org/software/emacs/manual/html_node/emacs/Option-Index.html#Option-Index

    【讨论】:

      【解决方案2】:

      @Toymakerii 的回答很好,但您也可以考虑添加:

      export PATH=/Applications/Emacs.app/Contents/MacOS/bin:$PATH
      

      这样,您可以使用emacsclient 在已经运行的 Emacs 实例中打开文件:

      emacsclient -t SOMEFILE   # Open SOMEFILE in a terminal frame
      emacsclient -c SOMEFILE   # Open SOMEFILE in a new graphical frame
      

      根据您的 Emacs 版本,您可能需要将以下内容放入您的 ~/.emacs.d/init.el(或 ~/.emacs,如果您是老式的):

      (require 'server)
      (unless (server-running-p)
        (server-start))
      

      【讨论】:

        【解决方案3】:

        在我的~/.profile 我有以下内容:

        function emacs
        {
            if [ -e "$@" ]
            then
                command open -a emacs "${@}"
            else
                touch "$@"
                command open -a emacs "${@}"
            fi
        }
        

        (之所以有函数是为了在启动emacs时指定文件还不存在的情况下也能工作)

        【讨论】:

        • 终于可以从终端正确打开emacs了。谢谢!
        【解决方案4】:

        默认情况下,终端将在 OS X 上打开 /usr/bin/emacs。 您可以通过更改“emacs”命令的功能来更改此行为。打开 ~/.profile 并输入以下内容:

        alias emacs=open /Applications/Emacs.app
        

        下次打开提示时,此更改将生效。 (或者你可以运行“source ~/.profile”)

        【讨论】:

        • 正确的命令是``` alias emacs='open /Applications/Emacs.app' ```,但我每次都需要运行"source ~/.profile"。
        【解决方案5】:

        最简单的就是做

        open /Applications/Emacs.app --args foo
        

        别名将是

        alias emacs=open /Applications/Emacs.app --args "${@}"
        

        或在 csh/tcsh 中

        alias emacs 'open /Applications/Emacs.app --args $1'
        

        编辑:这似乎需要一个完整路径才能打开正确的文件...我不知道这是 Emacs.app 还是 tcsh 的问题

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-11-03
          • 2022-07-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-12-09
          • 2015-12-20
          相关资源
          最近更新 更多