Run emacs as separate process from terminal

2019-08-12 18:53发布

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

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

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

2条回答
叼着烟拽天下
2楼-- · 2019-08-12 19:24

The emacs --help command is giving you a tip:

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

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

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

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 make etc...), or M-x gdb for a debugger.

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

查看更多
在下西门庆
3楼-- · 2019-08-12 19:34

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

There's a whole framework for working with backgrounded processes, see for example man jobs, disown, fg, bg, and try Ctrl-Z on 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, disown allows you to tell a program to keep running after you end your session.

查看更多
登录 后发表回答