What better way to welcome in the New Year than over-engineering a solution to an edge case that almost no one will need. Hurrah!
The thing is, sometimes I need to edit files on a remote server. This isn’t anything new or different, but sometimes I also want to use my editor of choice (VSCode), with all the shiny bits still shining.
There are ways of doing this, of course, including mounting the remote server over SSH (slow, doesn’t work well with code analysis), using remote editing extensions (I’ve never been able to get one to work reliably), or even just editing over FTP.
My own solution is a tool I’m prosaically calling simplesync. It monitors a directory for changes, and uploads them to the remote server. That’s it.
While I’m making no claims of it being a great solution, it does allow you to edit files locally, making full use of any editor features, and saves you having to manually upload stuff.
You run it as:
simplesync --local=dir —-remote=user@remote
You can store these settings in a local config file so you don’t need to remember anything.
A little extra bonus is:
This will sync changes from the remote server to your local machine. Handy for getting things set up in the first place, or for when files are changed on the server (only modified files will be downloaded).
As with any syncing it’s always worth testing the connection first, and you can do that by adding
--test to the command. This will output the local and remote file paths instead of doing the sync, allowing you to check that you’ve set things up properly.
How does it work?
rsync under the hood, combined with something to monitor for file changes.
What doesn’t it do?
Probably a lot of things. It doesn’t monitor changes on the remote server, and (currently) doesn’t handle new directories and deleted files well.
Why should I use it?
No reason. It works for my needs, should be platform independent (provided you have node setup), and it’s free.