Mikey Boldt About Contact

Emacs: <code>ssh</code> with Tab Completion

· Tech

Something that’s bugged me is that when I ssh into another machine inside a shell in emacs, tab completion gets still behaves as if I’m on the local machine. Just by chance, I once started a shell when using TRAMP to edit a remote file via scp, and noticed that the shell was on the remote machine and tab completion worked! So, I used this little in a function to start a remote with tab completion without manually opening a file on the remote machine first:

(defun remote-shell (&optional host)
  "Open a remote shell to a host."
  (interactive)
  (with-temp-buffer
    (let ((host (or host (read-string "Host: "))))
      (cd (concat "/scp:" host ":"))
      (shell (concat "*" host "*")))))

(defun myserver-shell () (interactive) (remote-shell "myserver"))

Comments

Steven · 2013-02-09

This is just what I was looking for. Thanks.

Tags: Emacs