We use ‘env’ to find ‘ruby’ so that it is still found if installed outside ‘/usr/bin’ (presuming its location is listed in the PATH environment variable). Since not all implementations of ‘env’ support additional arguments to the executable we wish to run, there now is an encoding comment to replace the -KU argument (for ruby 1.9).
This allows setting the default host/port as environment variables and additionally, if the server accepts environment variables from the connecting client, solves the problem where multiple clients connects to the same account (e.g. same user on different machines).
…a path that doesn't yet exist!
…e. This is to support GIT_EDITOR and other such use-cases.
…the begining of the script.
… to open with -f / --force.
Presently it sends an empty string as the file data to the server. This cause a proxy icon to show for the file which is misleading. Ideally it shouldn’t send any file data, but that’ll cause “Save” to be treated as “Save As…” (will be fixed later).
FileUtils.cp throws an exception on failure (rather than false return), as will a failed File.open, so this allows us to catch errors in a simple rescue block. FileUtils.cp will try to overwrite an existing file at the target path, so there is no need to explicitly unlink an existing backup first. Long-term we probably want some way for rmate to notify the server that the save failed.
…content, instead of creating a new file.
This is not saving back (on the server) but otherwise works. It takes one or more files as argument and opens this in the local version of Avian. I have this in my .ssh/config for the host: RemoteForward 25757 localhost:25757 ForwardAgent yes ControlPath ~/.ssh/master-%r@%h:%p ControlMaster auto The first line is the essential one, the next ones are so that it re-uses the connection, that way, it won’t try to setup forward for same port if a second session is opened. The protocol with Avian is very simply, it is: First line is just «command» and then zero or more «variable»: «value» to provide settings. One special case is that the variable ‘data’ has a integer as value which tells how many raw bytes should be read next, after those, more variables may follow (even another data variable, in which case the bytes read should be appended to those already read, this is to allow transferring data in chunks, e.g. TM may not know in advance how many bytes a file will amount to (due to encodings and such)). The rmate app tells Avian that it wants the file data back on save with ‘data-on-save: YES’ (look in the source). Avian sends back ‘save’ as command and then the data via the variable system explained above. It sends back the ‘close’ command when a file is closed. It puts the token among the variables sent back if one was provided during open.