2

When I want to access remote files over sftp in Emacs using TRAMP, I would like Emacs to offer me completions from the hostnames in my ssh config. How can I do this?

For example, if I have two hosts in my ssh config, "alpha" and "bravo", when I type /sftp:a at the find-file prompt, it should complete "alpha".

1 Answers1

5

Remote access is documented in the Tramp manual. You want the section on customizing completion. Put something like this in your ~/.emacs:

(setq my-tramp-ssh-completions
      '((tramp-parse-sconfig "~/.ssh/config")
        (tramp-parse-shosts "~/.ssh/known_hosts")))
(mapc (lambda (method)
        (tramp-set-completion-function method my-tramp-ssh-completions))
      '("fcp" "rsync" "scp" "scpc" "scpx" "sftp" "ssh"))