I connect to various locations, for example:


and want to have some kind of short aliases for these long paths. Something like this:


How can I get it?

2 Answers 2


Just use environment variables for the tramp paths.

For an example you could add the following line to your init file (with the right substitution for hostname):

(setenv "suHn" "/ssh:hostname|sudo:hostname:")

Those variables are resolved if you use them like $suHn/ at the prompt of find-file.

Note however that I am not sure about the pipe-character | in your tramp path. I never used such syntax for tramp and it is also not mentioned in tramp's file name conventions.

  • Thank you, it is the most useful approach at the moment.
    – artscan
    Apr 15, 2019 at 5:50

Read the Tramp Manual, chapter Frequently Asked Questions (https://www.gnu.org/software/tramp/#Frequently-Asked-Questions). It explains in length several approaches to shorten remote file names. These approaches are valid also for multi-hop file names.

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.