Work Locally Save Remotely with Textmate
Saturday, November 29th, 2008This is a method of working on a project locally and saving to a remote staging server.
You will need to be able to rsync to the remote computer without using a password. For this you will need to set up an ssh key.
Add the following shell script to Textmate as a command with input is set to none, output is set to Show as tooltip and my key equivalent is set to control+command+s (or whatever you like)
RSYNC_USER=${RSYNC_USER:-defaultUsername}
RSYNC_HOST=${RSYNC_HOST:-defaultHost}
if [ "${RSYNC_DIR}" ]; then
rsync -av --exclude "CVS*" --exclude "*.kpf" --exclude ".DS_Store" $RSYNC_DIR $RSYNC_USER@$RSYNC_HOST:$RSYNC_REMOTE
fi
Textmate can accept variables for this script on a per project basis. To do this open your project, make sure no files are hi-lighted in the project drawer then click on the “i” info icon at the bottom of the project drawer. Here you can add your required variables.
RSYNC_USER The user
RSYNC_DIR The local directory from which the rsync will be made. eg. “/User/me/Sites/myProject/”
RSYNC_REMOTE The remote directory in which to rsync. eg. “/var/www/myProject”
RSYNC_HOST The host name of the remote server.
Tip: It is always a good idea to echo out the rsync command and have a look at what it is doing before you let it run.
