macos 如何在终端中启动“emacsformacosx”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9149868/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:50:06  来源:igfitidea点击:

How to start "emacsformacosx" in terminal

macosemacs

提问by why

I am using MAC OX 10.6 , and install the emacs from here http://emacsformacosx.com/

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

I want to know how to start it in terminal, so my ecb can open current directory

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

回答by Fr. John Jenkins

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.

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

You can put the following in your shell (on my mac .zshenv) :

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

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

Then I just have two commands:

然后我只有两个命令:

Emacs: for emacs version 24

Emacs: 对于 emacs 版本 24

emacs: for the apple version of emacs

emacs: 苹果版的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.app 别名为 emacs,但这允许我以不同的方式自定义两者 - 例如 Emacs 24 允许我使用列表包等等。emacs 22 忽略了大部分内容,因此如果需要,我总是可以恢复到“裸机”emacs。您的用法可能会有所不同,但如果您不记得 emacs 的参数,您可以通过执行以下操作找到它们:

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

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

回答by sanityinc

The answer from @Toymakerii is a good one, but you might also consider adding:

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

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

This way, you can use emacsclientto open files in an already-running Emacs instance:

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

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

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

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

回答by Johan Lübcke

In my ~/.profilei have the following:

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

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)

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

回答by Rok

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

或在 csh/tcsh

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

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

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

回答by Toymakerii

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:

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

alias emacs=open /Applications/Emacs.app

The next time you open a prompt this change will be active. (or you can run "source ~/.profile")

下次打开提示时,此更改将处于活动状态。(或者你可以运行“source ~/.profile”)