Every now and then I need to work on a system that has so many dependencies that it’s easiest to run it on a remote machine. Previously, I’ve used
sshfs to mount the remote file system locally and worked on the project in
vim that way but the internet connection I was using wasn’t great, so that wasn’t an option.
Initially, I was going to try out PHPStorm and it’s SFTP functionality, but then Nils reminded me that I could use something to watch the code directory and rsync it with the remote host automatically. I was going to hack something together with
rsync initially but a quick Google lead me to lsyncd.
lsyncd is awesome. So, so simple to set up. Just run the following command to make sure that files are synced as soon as they are saved
lsyncd -rsync /path/to/code remotehost.org:/target/path -delay 0 -nodaemon
-nodaemon flag will run it in the foreground so that you can make sure things are working as expected. You can delete this flag if you want it to run in the background.
Michael is a polyglot software engineer, committed to reducing complexity in systems and making them more predictable. Working with a variety of languages and tools, he shares his technical expertise to audiences all around the world at user groups and conferences. You can follow @mheap on Twitter