Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs as a screen/tmux alternative - detach from terminal

It's well known that emacs can be used as a terminal emulator (while itself is running in a terminal emulator), thus making it a valid alternative to more traditional terminal-in-a-terminal approaches, such as tmux or screen. However, there's one thing that could be done easily with the latter and I've found no alternative in emacs' term for this one so far.

Both tmux and screen can detach from a terminal and all tasks ran in their windows continue to run in background. It's done using C-b, d in tmux and C-a, d in screen by default. Later, I can return (reattach) to the terminal I've detached from by running something like tmux attach or screen -r. Also, sessions run in both of these terminal multiplexers are persistent - i.e. if I'm connected to some remote terminal and connection fails, I can reconnect and reattach to the terminal without losing any of my work - it really helps in case of faulty network link that occasionally breaks ssh connections.

Is there something like that available for emacs? Basically, I'd want to be able to:

  • Detach from emacs and leave it running in background with all the sub-processes ran in term buffers intact.
  • Reattach to it later and find all my processes running.
  • Automatic detachment of emacs from terminal on receiving a SIGHUP.
like image 473
GreyCat Avatar asked Sep 03 '12 02:09

GreyCat


1 Answers

Use emacs daemon:

$ emacs --daemon

Then simply launch a new frame, equivalent for screen -x:

$ emacsclient -t
like image 188
Yno Avatar answered Oct 14 '22 08:10

Yno