xeno

12 July 2013 in projects

xeno is a simple command line application for editing files and folders on a remote machine using your local text editor.

Easy editing

I’ve been a bit fed-up lately with remotely editing files. Sure you can use vim or emacs in a pinch for a one-off edit, or sync everything through a central Git repository, but if you’re trying to do any non-trivial edits to a website or application that really needs to be deployed remotely to operate, and you’re not a vim-ninja, things rapidly become tedious. Add to that the fact that you often have to leave behind the perfectly good text editor that you paid $70 for, have to deal with the high latency of key presses, and transfer any editor configuration - it all becomes very… irritating.

There are a couple of remote editing options at present, but they all suffer from one weakness or another. In particular, they either only allow you to edit a single file at a time, or they require complex kernel extentions and invocations to make work. Worst of all, none of them are robust against connection dropouts. Some of the more popular options:

  • SSHFS: This is generally speaking the most popular option. On many Linux systems, this is baked-in, which is great, but in my own (heavily-biased) experience, most developers are using a Mac and connecting remotely to some Linux system. There are obviously Mac ports of FUSE and SSHFS, but they are difficult to install, requiring a special kernel extension and complicated mount commands. There is a fantastic app called MacFusion which makes all this very easy, but again it is Mac only, and it only supports modern versions of OS X on some GitHub forks.
  • Cyberduck: With Cyberduck, you can edit files on a remote server in your local editor, although it only supports a single file at a time.
  • rmate: rmate takes a slightly different approach, in that it is meant to be invoked over an active SSH connection, although it also only supports a single file at a time, and without some hacks, only works with TextMate.

The list goes on, but the issues are relatively the same. I needed something different…

Enter xeno

Frustrated, I’ve spent a couple weekends putting together a slightly more minimalist and cross-platform replacement - xeno. It is largely geared towards my own usage patterns, and the usage reflects that.

xeno uses a Git/SSH mashup as its underlying transport and synchronization mechanism. When xeno is invoked, it will generate an out-of-work-tree Git repository on the remote machine to track and coordinate changes. xeno will then clone the remote repository, launch your local editor on the clone, and launch a daemon to keep the local and remote in-sync.

Because the remote Git repository is outside of the work tree, you can use it to edit remote folders which may already be Git repositories without any conflicts. xeno also works for editing single remote files. Best of all, because it uses Git, it will safely merge changes to and from the remote, and if your local editor is Git-aware, it will show you which changed files have or haven’t been synced to the remote.

Usage

xeno provides a variety of commands for starting, managing, resuming, and ending sessions. xeno is robust, and the daemon will continue trying to sync changes to the remote repository even if SSH access becomes temporarily unavailable. When the editing session is ended, xeno will automatically clean up all local and remote resources.

To start editing a remote path over SSH, use

$ xeno edit [email protected]:/the/path

xeno will clone the remote path locally and keep it in sync with the remote copy. Or, if you are already in an SSH session1, you can do

$ xeno edit /the/path

and it will have exactly the same effect!

1: For in-session launches, you must use xeno ssh, a VERY thin wrapper around SSH which monitors console output for initialization messages

Features

xeno uses a variet of subcommands to do its bidding (e.g. config, edit, …). To view help information for a particular subcommand, use:

$ xeno SUBCOMMAND_NAME --help

xeno supports the following subcommands:

  • edit: Starts editing sessions
  • config: Manages xeno configuration information
  • ssh: A pass-through to ‘ssh’ which monitors console output for session initialization
  • list: Lists active xeno sessions
  • resume: Resumes a xeno session (open your editor on the local copy)
  • stop: Stops a xeno session and cleans up local/remote resources
  • sync: Syncs a xeno session with the remote copy (automatically run as a daemon when using xeno edit to do periodic synchronization, and also available to manually push/pull changes on-demand)

For convenience, you can alias the xeno edit as xen. To keep consistency, if you use the xeno edit command on a local path, it will simply open the local path in your editor, so you don’t have to use a different command to launch your local editor.

More Information

xeno is written as a shell script, and is free and open-source. For more information, you can check out xeno’s official site. Feedback is very welcome and encouraged!


Tags: 

comments powered by Disqus