using rsync with Textmate to sync local and remote files
- Set up passwordless authentication to securely sign in to your remote host without keyboard authentication. Otherwise you will have to enter your password each time your run the command, and as well you won’t be able to synchronize from Textmate.
- To “perform a trial run with no changes made”, run this command in the terminal:
rsync -e "ssh -i /path/to/keygen" -auv --delete --dry-run ~/path/to/local/content/ remoteSSHUser@remote-server.org:/path/to/remote/content/. - Once you have it right, remove remove
--dry-runand add the command to Textmate via a bundle.
Extra Credit
Use Textmate variables and the command will work for each of your projects (thanks to Allan and rbrtrx via the Textmate IRC channel)
rsync -e "ssh" -auv --delete "${TM_SSH_PORT:+ --port=$TM_SSH_PORT}" "$TM_PROJECT_DIRECTORY"/ "${TM_SSH_USER:+$TM_SSH_USER@}$TM_SSH_HOST:$TM_SSH_REMOTE_PATH"
Notes
- rsync is picky about trailing slashes.
- Mailing list thread regarding this post
- Another good page on rsync, including how to exclude .DS_Store files, etc.
Using Transmit’s Synchronize Feature
Note: Using Panic’s Transmit you can use the synchronize command, which allows you to either update or mirror your files (from client to server or vice-versa). This does essentially the same thing as rsync, however you have to switch apps over to Transmit from Textmate, select the command, confirm your action twice and then watch the files go. Short term this is more efficient than setting up rsync, ssh and textmate.
Using SVN
I’ve stopped using rsync altogether. SVN allows one to work across multiple machines and merge changes, revert changes, compare previous versions, etc. etc. Textmate has a very capable SVN bundle, and dreamhost provides easy administration of svn repositories.
* * *