A VS Code extension that implements TextMate's rmate feature, allowing files on a remote machine to be opened and edited in your local VS Code window over an SSH tunnel.
Fork lineage
This repository is a fork of dersimn/rmate-vscode, which is itself a fork of Rafael Maiolla's original rafaelmaiolla/remote-vscode. Thanks to Simon Christmann, Rafael Maiolla, and the other contributors for the work this version builds upon.
This fork adds automatic cleanup of RMate sessions when their VS Code tabs are closed. It also retains improvements from the dersimn fork, including:
Open multiple files at once with rmate file1 file2
Close files opened with the -w flag, which is useful when using rmate in the EDITOR environment variable.
Example: EDITOR='rmate -w' sudoedit somefile
When the VS Code tab is closed, the corresponding RMate session is closed as well.
Alternatively, commands are available for closing individual sessions or all sessions at once:
Installation
Install duncannah.rmate-vscode from the VS Code Extension Marketplace. Marketplace installations can be carried to your other desktop machines by VS Code Settings Sync.
Install an rmate client on the remote machine.
I recommend aurora/rmate over the original one, as you avoid a Ruby dependency! (rmate-rs in nixpkgs)
Usage
Configure the extension in VS Code Settings.
Start the server in the command palette - Press F1 or ⌘ Command + ⇧ Shift + P and type rmate: Start server, and press ⏎ Enter to start the server.
If successfully started you'll see a symbol in Status Bar:
Login to your remote server with a remote port tunnel
ssh -R 52698:127.0.0.1:52698 user@example.org
Or configure SSH to always create a tunnel by editing ~/.ssh/config:
Host *
RemoteForward 52698 127.0.0.1:52698
Go to the remote system and run
rmate file1 file2
If you want to use rmate in EDITOR variable, you can use it like this:
EDITOR='rmate -w' sudoedit important_file
Extra: if you have a shared shell config, you can have it set EDITOR only for SSH sessions, in your .bashrc or .zshrc:
if [[ -n "$SSH_CONNECTION" ]]; then
export EDITOR='rmate -w'
fi
Credits and license
This project is maintained by duncannah and derives from work by Simon Christmann, Rafael Maiolla, and their contributors. See the repository history for the complete contribution record.