I was getting tired of waiting to fire up Transmit every time I wanted to edit a file with TextMate over FTP, so I decided to create my own modest script, I decided to post it here just in case anybody else found it useful
--- Start "ftpmate" #!/usr/bin/env bash REMOTE_FILE=$(echo $1 | awk -F '/' '{print $NF}') LOCAL_FILE="/tmp/"$REMOTE_FILE CD="/Applications/TextMate.app/Contents/SharedSupport/Support/bin/ CocoaDialog.app/Contents/MacOS/CocoaDialog bubble --background-top EFEFEF --background-bottom CACACA --icon-file /Applications/ TextMate.app/Contents/Resources/TextMate.icns" ftp -o $LOCAL_FILE ftp://$1 if [[ $? = "0" ]]; then MD5_OUT=$(md5 $LOCAL_FILE) mate -w $LOCAL_FILE if [[ "$MD5_OUT" != "$(md5 $LOCAL_FILE)" ]]; then ftp -u ftp://$1 $LOCAL_FILE if [[ $? = "255" ]]; then $CD --title "FTPMate" --text "$REMOTE_FILE updated" & else $CD --title "FTPMate" --text "Unable to update $REMOTE_FILE" & fi fi rm -r $LOCAL_FILE else $CD --title "FTPMate" --text "Unable to retrieve $REMOTE_FILE" & fi --- End
usage : ftpmate [user[:password]@]host[:port]/path
The script attempts to fetch the file and writes it to /tmp/ where it is opened by TextMate, after the 'mate' process has ended a checksum is compared to the pre-opened checksum and if it has changed then the file is uploaded.
I decided to use the bubble requester in the CocoaDialog app because I am calling the script outside a shell session and want to know the file had successfully been uploaded.
Likewise I also made a script using SCP instead of FTP
--- Start "scpmate" #!/usr/bin/env bash REMOTE_FILE=$(echo $1 | awk -F '/|:' '{print $NF}') LOCAL_FILE="/tmp/"$REMOTE_FILE CD="/Applications/TextMate.app/Contents/SharedSupport/Support/bin/ CocoaDialog.app/Contents/MacOS/CocoaDialog bubble --background-top EFEFEF --background-bottom CACACA --icon-file /Applications/ TextMate.app/Contents/Resources/TextMate.icns" scp $1 $LOCAL_FILE if [[ $? = "0" ]]; then MD5_OUT=$(md5 $LOCAL_FILE) mate -w $LOCAL_FILE if [[ "$MD5_OUT" != "$(md5 $LOCAL_FILE)" ]]; then scp $LOCAL_FILE $1 if [[ $? = "0" ]]; then $CD --title "SCPMate" --text "$REMOTE_FILE updated" & else $CD --title "SCPMate" --text "Unable to update $REMOTE_FILE" & fi fi rm -r $LOCAL_FILE else $CD --title "SCPMate" --text "Unable to retrieve $REMOTE_FILE" & fi --- End
usage : scpmate [user@]host:path
On Jun 19, 2006, at 10:46 AM, Andy Herbert wrote:
I was getting tired of waiting to fire up Transmit every time I wanted to edit a file with TextMate over FTP, so I decided to create my own modest script, I decided to post it here just in case anybody else found it useful
I gave the scpmate script a quick test and it worked great for me, Andy. Thanks!
-Alan