bash 将 emacs 作为独立于终端的进程运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17972119/
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-09-18 06:05:03  来源:igfitidea点击:

Run emacs as separate process from terminal

linuxbashunixemacsterminal

提问by ojhawkins

When I run the emacstext editor the process does not return so I cannot use the terminal which is obviously the default behavior.

当我运行emacs文本编辑器时,进程不会返回,因此我无法使用终端,这显然是默认行为。

I cannot find the switch or command in the manbut I know it is something very simple.

我在 中找不到开关或命令,man但我知道它非常简单。

How can I run emacsas a separate process so I can continue to use the terminal without opening a second one?

如何emacs作为一个单独的进程运行,以便我可以继续使用终端而无需打开第二个?

回答by Dan

You can start any program in the background by appending an ampersand to the command, emacs &.

您可以通过在命令emacs &.

There's a whole framework for working with backgrounded processes, see for example man jobs, disown, fg, bg, and try Ctrl-Zon a running process, which will suspend it and give you the terminal, allowing you to resume that process either in the foreground or background at your pleasure. Normally when your shell closes, all those programs will end, disownallows you to tell a program to keep running after you end your session.

有与转到后台处理工作的整体框架,见例如man jobsdisownfgbg,并尝试Ctrl-Z对正在运行的进程,这将暂停,并给你的终端,让你恢复这一进程要么在你的快乐前景或背景。通常当你的 shell 关闭时,所有这些程序都会结束,disown允许你告诉程序在你结束会话后继续运行。

回答by Basile Starynkevitch

The emacs --helpcommand is giving you a tip:

emacs --help命令为您提供了一个提示:

   --batch             do not do interactive display; implies -q

So run emacs --batch(or maybe emacs --executesomecommand).

所以运行emacs --batch(或者可能emacs --executesomecommand)。

If you have a desktop (or some X11 display) and want emacsto open an X11 windows and give you back a shell prompt, run it in the background (e.g. emacs &) as many commented.

如果您有一个桌面(或一些 X11 显示器)并且想要emacs打开 X11 窗口并返回一个 shell 提示,请在后台运行它(例如emacs &)。

And I find very useful to start programs (or shells) within emacs, e.g. with Emacs commands: M-x shell, or M-x compile(for makeetc...), or M-x gdbfor a debugger.

而且我发现在 emacs 中启动程序(或 shell)非常有用,例如使用 Emacs 命令:M-x shell,或M-x compile(用于make等...),或M-x gdb用于调试器。

You usually start one single emacsat the beginning of a working day. You could use emacsclient(or set your EDITORenvironment variable to it) for other editions using the same emacs.

你通常emacs在工作日开始时开始一首单曲。您可以使用emacsclient(或将您的EDITOR环境变量设置为)其他版本使用相同的emacs.