11

I often use GNU Screen to keep remote sessions alive. Since I live in Emacs, I'd really like to be able to resume a running remote shell session from within Emacs.

GNU Screen implements all sorts of fancy things like terminal multiplexing and character drawing that I really don't need. I'm really only interested in having detachable and resumable shell sessions, so something as simple as dtach might be sufficient.

I'm using this function to open an SSH session and reconnect to a running dtach session in shell-mode (taken from here):

(defun ssh-dtach (host)
  "Open SSH connection to remote host and attach to dtach session."
  (interactive)
  (let ((explicit-shell-file-name "dtach")
        (explicit-dtach-args '("-A" "/tmp/emacs.dtach" "-z"
                               "/bin/bash" "--noediting" "-login"))
        (default-directory (format  "/ssh:%s:" host)))
    (shell (format "*ssh %s*" host))))

Despite minor quirks, this works almost fine for shell-mode, but in Eshell this just starts a subprocess, so the terminal becomes very limited (e.g. no path autocompletion).

How can I configure Eshell to connect to a running dtach session upon connecting to a remote server?

EDIT: As I thought about this problem again, I realised that it isn't entirely clear what I actually want. Here's a list:

  • I want to stay in eshell, not in some subprocess
  • upon reattaching I want the output of the remote session to be replayed and the remote command history to be available
  • I want to be able to interact with a running remote process (e.g. a running yum install waiting for my input)

It seems that I'll need to write a bit of elisp code to make this all work with dtach.

  • shell-mode interacts with a shell process, eshell IS the shell -- so conceptually it seems to me you can't do what you want, unless you access a running emacs with an eshell buffer in the dtach session. Or am I mistaken here? – Tom Regner Oct 31 '14 at 8:32
  • In eshell the lines between what is local and what is remote and what is an external command and an elisp function are blurred. I'd like to make it even fuzzier such that remote running processes can be interacted with transparently as if they were local. That would be almost the same as "resuming" a running session, I think. – rekado Oct 31 '14 at 8:59
  • Related: stackoverflow.com/questions/16819248/… – sds Oct 31 '14 at 14:05
  • @sds: running screen inside of shell-mode is not going to work well, because screen needs more than a dumb terminal. – rekado Oct 31 '14 at 14:22
2

Maybe not satisfactorily, but this issue is on the Tramp wish list. Maybe it will be implemented some day.

See the discussion on the Emacs Devel ML http://thread.gmane.org/gmane.emacs.devel/174131

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.