Tim Landscheidt <[email protected]> writes:
> I don't know if it fits your use case, but there is also
> tramp-remote-process-environment which can be used to set
> environment variables on (all) remotes.

Thanks. Unfortunately it is not sufficient for my use case because the
setup on each host varies.

I was hoping that it is possible to add a new custom tramp method, e.g.
called "sudoi", and after some dabbling around came up with this:

#+begin_src elisp :results none
(add-to-list 'tramp-methods
             '("sudoi" (tramp-login-program "env")
              (tramp-login-args
               (("sudo")
                ("-u" "%u") ("-i") ("%l")))
              (tramp-remote-shell "/bin/sh")
              (tramp-remote-shell-args ("-c"))))
#+end_src

which is a stripped copy of the entry for "sudo" with the sudo option
"-c" replaced by "-i". Now this remote path:

/ssh:example.com|sudoi:[email protected]:

sources the remote profile. Not sure if 'tramp-methods was meant to be
extended this way, but it works for me so far. And it has the benefit
that when the configuration is not present, it will fail right away with
the message "Method ‘sudoi’ is not known".


cheers, Til

Attachment: signature.asc
Description: PGP signature

Reply via email to