For the complete documentation index, see llms.txt. A markdown version of this page is at /workstations/connectivity/file-transfer/index.md.

File transfer

`rl file cp` copies a file or a directory between your computer and a workstation, in the style of `scp`.

rl file cp copies a file or a directory between your computer and a workstation, in the style of scp. It needs no SSH setup, and a script can run it. Use it for a copy you make once. For a folder that the workstation should see at all times, share the folder instead.

Local and remote paths

One side of a copy is a local path, and the other is workstation:path. A colon before any slash makes an argument remote, so a local file whose name contains a colon is written ./name.

  • An empty workstation name, as in :/tmp/notes.md, picks the workstation that rl shell would pick, as Workstation choice for shell and tmux describes.
  • An empty path, as in my-box:, is the login user’s home directory.

Destination of a copy

The destination is the path that will exist afterward. The one exception follows cp(1) and applies to a single file only. A destination that names an existing directory, or ends in a separator, receives the file under its own name.

A -r copy never adds a name to the destination. Running it twice does what running it once did. scp would nest dir/dir on the second run.

Guarantees of a copy

  • A single file lands by a rename, so a transfer that fails leaves the destination exactly as it was.
  • A -r copy merges into its destination. It is not atomic as a tree, though each file in it still is.
  • A download never creates symbolic links. A directory that you copy up follows only the links that stay inside it.
  • Any transfer that fails exits with a non-zero code and says what failed.

File locations in a devcontainer workstation

The remote side of a copy is the file system that a bare rl shell lands on. On a workstation that runs a devcontainer, that is inside the container. A path you copy to is the path you then see in a shell. The workspace folder holds the same files either way, because the container mounts it.

--host copies to and from the workstation’s virtual machine instead. Use it for a path outside the workspace folder. Devcontainer shell and file locations shows where scp, sftp, rsync and rl file cp land.

Copy a file to or from a workstation

To upload a file, put the local path first. To download one, put the workstation path first:

rl file cp ./notes.md my-box:/tmp/notes.md -n local
rl file cp my-box:/tmp/notes.md ./notes.md -n local

To copy a directory in either direction, add -r:

rl file cp -r ./src my-box:/home/dev/src -n local

Share a folder instead of copying

A shared folder keeps a folder on your Mac in view of a vz workstation, with no copy to repeat. Shared folders from your Mac explains them. qemu, hcs and the cloud providers share no folders. On those workstations, rl file cp is the way to move files.

Next steps