Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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"))
share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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