5.1.3 Electric forward slash

To help with supplying absolute file name arguments to remote commands, you can add the eshell-elecslash module to eshell-modules-list. Then, typing / as the first character of a command line argument will automatically insert the Tramp prefix /method:host:. If this is not what you want (e.g. because you want to refer to a local file), you can type another / to undo the automatic insertion. Typing ~/ also inserts the Tramp prefix. The automatic insertion applies only when default-directory is remote and the command is a Lisp function. In particular, typing arguments to external commands doesn’t insert the prefix.

The result is that in most cases of supplying absolute file name arguments to commands you should see the Tramp prefix inserted automatically only when that’s what you’d reasonably expect. This frees you from having to keep track of whether commands are Lisp functions or external when typing command line arguments. For example, suppose you execute

 cd /ssh:root@example.com:
 find /etc -name "*gnu*"

and in reviewing the output of the command, you identify a file /etc/gnugnu that should be moved somewhere else. So you type

 mv /etc/gnugnu /tmp

But since mv refers to the local Lisp function eshell/mv, not a remote shell command, to say this is to request that the local file /etc/gnugnu be moved into the local /tmp directory. After you add eshell-elecslash to eshell-modules-list, then when you type the above mv invocation you will get the following input, which is what you intended:

 mv /ssh:root@example.com:/etc/gnugnu /ssh:root@example.com:/tmp

The code that determines whether or not the Tramp prefix should be inserted uses simple heuristics. A limitation of the current implementation is that it inspects whether only the command at the very beginning of input is a Lisp function or external program. Thus when chaining commands with the operators &&, ||, | and ;, the electric forward slash is active only within the first command.