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".

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"))
  • Close enough. I just had to replace "ssh" with "sftp". Actually, I set it for both. – Ryan Thompson Oct 26 '10 at 1:00
  • Oh, wow. There are a lot of ssh-based methods, aren't there? I don't even know what half of those are. – Ryan Thompson Oct 27 '10 at 4:51

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.