Next: Control Flow, Previous: Aliases, Up: Commands [Contents][Index]
Since Eshell uses Emacs facilities for most of its functionality, you
can access remote hosts transparently. To connect to a remote host,
simply cd
into it:
~ $ cd /ssh:user@remote: /ssh:user@remote:~ $
Additionally, built-in Eshell commands (see Built-in Commands) and ordinary Lisp functions accept remote file names, so you can access them even without explicitly connecting first. For example, to print the contents of a remote file, you could type ‘cat /ssh:user@remote:~/output.log’. However, this means that when using built-in commands or Lisp functions from a remote directory, you must be careful about specifying absolute file names: ‘cat /var/output.log’ will always print the contents of your local /var/output.log, even from a remote directory. If you find this behavior annoying, you can enable the optional electric forward slash module (see Electric forward slash).
When running commands, you can also make them explicitly remote by
prefixing the command name with a remote identifier, e.g.
‘/ssh:user@remote:whoami’. This runs the command whoami
over the SSH connection for user@remote
, no matter your current
directory. If you want to explicitly run a command on your local
machine even when in a remote directory, you can prefix the command name
with /local:, like ‘/local:whoami’. In either case, you can
also specify the absolute path to the program, e.g.
‘/ssh:user@remote:/usr/bin/whoami’. If you need to refer to a
program whose file name would be interpreted as an explicitly-remote
command, you can use /: to quote the name, e.g.
‘/:/ssh:user@remote:whoami’ (see Quoted File Names in The GNU Emacs Manual). To disable explicitly-remote commands entirely,
you can set the option eshell-explicit-remote-commands
to
nil
.
Next: Control Flow, Previous: Aliases, Up: Commands [Contents][Index]