Permalink
Browse files

Added Growl support

Update to work with TextMate 2 and Growl
  • Loading branch information...
1 parent 1c4b73d commit 061234a84c81478002123781f46b1f2670f29973 @davidolrik committed Dec 19, 2011
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
- <string>
+ <string>#!/bin/bash
+source "$TM_SUPPORT_PATH/lib/bash_init.sh" # might not be necessary
. "$TM_BUNDLE_SUPPORT/bin/environment.sh"
if [ ! -e "$CONFIG_FILE" ]; then
cat "$TM_BUNDLE_SUPPORT/templates/config.sh" &gt; "$CONFIG_FILE"
fi
mate -a "$CONFIG_FILE"
- </string>
+</string>
<key>input</key>
<string>none</string>
<key>name</key>
@@ -1,19 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>saveActiveFile</string>
<key>command</key>
- <string> . "$TM_BUNDLE_SUPPORT/bin/environment.sh"
+ <string>#!/bin/bash
+source "$TM_SUPPORT_PATH/lib/bash_init.sh" # might not be necessary
+ . "$TM_BUNDLE_SUPPORT/bin/environment.sh"
. "$TM_BUNDLE_SUPPORT/bin/test_for_project.sh"
. "$TM_BUNDLE_SUPPORT/bin/load_config.sh"
+
+ print_message "Copy file to remote" "${TM_FILEPATH/$TM_PROJECT_DIRECTORY\//} to $REMOTE_HOST"
+
OUT=$(scp -P "$REMOTE_PORT" "$TM_FILEPATH" "$REMOTE_USER@$REMOTE_HOST:'$REMOTE_PATH${TM_FILEPATH/$TM_PROJECT_DIRECTORY/}'" 2&gt;&amp;1)
if [ -n "$OUT" ]; then
- echo "$OUT"
+ error_message "Error" "$OUT"
else
- echo "${TM_FILEPATH/$TM_PROJECT_DIRECTORY\//} synced ok"
- fi</string>
+ print_message "Copy completed ok" "${TM_FILEPATH/$TM_PROJECT_DIRECTORY\//}"
+ fi
+ if [[ -n "$REMOTE_POST_COMMAND" ]]; then
+ print_message "Running remote post command" "$REMOTE_POST_COMMAND"
+ OUT=$(ssh -f -p "$REMOTE_PORT" "$REMOTE_USER@$REMOTE_HOST" -- "cd \"$REMOTE_PATH\" &amp;&amp; $REMOTE_POST_COMMAND 2&gt;&amp;1") &amp;&amp; print_message "Remote post command complete" "$OUT"
+ fi
+</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
@@ -1,25 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>saveModifiedFiles</string>
<key>command</key>
- <string>
+ <string>#!/bin/bash
+source "$TM_SUPPORT_PATH/lib/bash_init.sh" # might not be necessary
. "$TM_BUNDLE_SUPPORT/bin/environment.sh"
. "$TM_BUNDLE_SUPPORT/bin/test_for_project.sh"
. "$TM_BUNDLE_SUPPORT/bin/load_config.sh"
echo "&lt;h1&gt;Synchronize project&lt;/h1&gt;"
+ echo "&lt;h3&gt;$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH&lt;/h3&gt;"
echo "&lt;pre&gt;"
cd "$TM_PROJECT_DIRECTORY"
- rsync -v -zar $RSYNC_OPTIONS --exclude ".tm_sync.config" -e "ssh -p $REMOTE_PORT" \
+ RSYNC_CMD="rsync -v -zar --exclude=.tm_sync.config $RSYNC_OPTIONS"
+ echo $RSYNC_CMD
+ echo
+ $RSYNC_CMD -e "ssh -p $REMOTE_PORT" \
. "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH" 2&gt;&amp;1 \
| grep -v 'bind: Address already in use' \
| grep -v 'channel_setup_fwd_listener: cannot listen to port:' \
| grep -v 'Could not request local forwarding.'
echo "&lt;/pre&gt;"
- cd -
+ cd - 2&gt;&amp;1 &gt; /dev/null
+ echo "&lt;b&gt;Synchronize complete!&lt;/b&gt;"
+ if [[ -n "$REMOTE_POST_COMMAND" ]]; then
+ echo "&lt;h3&gt;Running remote post command&lt;/h3&gt;"
+ echo "&lt;b&gt;\$ $REMOTE_POST_COMMAND&lt;/b&gt;";
+ OUT=$(ssh -f -p "$REMOTE_PORT" "$REMOTE_USER@$REMOTE_HOST" -- "cd \"$REMOTE_PATH\" &amp;&amp; $REMOTE_POST_COMMAND 2&gt;&amp;1")
+ echo "&lt;pre&gt;"
+ echo "$OUT"
+ echo "&lt;/pre&gt;"
+ echo "&lt;b&gt;Remote post command complete!&lt;/b&gt;";
+ fi
</string>
<key>input</key>
<string>none</string>
View
@@ -2,3 +2,33 @@
export CONFIG_FILE="$TM_PROJECT_DIRECTORY/.tm_sync.config"
+if [[ -x /usr/local/bin/growlnotify ]]; then
+ export GROWLNOTIFY="/usr/local/bin/growlnotify"
+elif [[ -x ~/bin/growlnotify ]]; then
+ export GROWLNOTIFY="~/bin/growlnotify"
+fi
+
+function print_message {
+ TITLE="$1"
+ MESSAGE="$2"
+
+ if [[ -n "$GROWLNOTIFY" ]]; then
+ $GROWLNOTIFY -a TextMate -t "${TITLE}" -m "${MESSAGE}"
+ else
+ echo "${TITLE}: ${MESSAGE}"
+ fi
+}
+
+function error_message {
+ TITLE="$1"
+ MESSAGE="$2"
+
+ if [[ -n "$GROWLNOTIFY" ]]; then
+ $GROWLNOTIFY -a TextMate -t "${TITLE}" -m "${MESSAGE}" -p 2 -s
+ else
+ echo "${TITLE}: ${MESSAGE}"
+ fi
+}
+
+
+
@@ -9,8 +9,11 @@ REMOTE_USER="username"
REMOTE_PATH="/remote/directory"
# Here you can parse options on to rsync if you e.g. want to exclude files
-RSYNC_OPTIONS="--exclude blib --exclude _build --exclude Makefile --exclude Build"
+RSYNC_OPTIONS="--exclude=.git --exclude=blib --exclude=_build --exclude=Makefile --exclude=Build --delete"
# Use the rsync option below with caution, as it replaces the remote directory
# with the contents of your project.
-#RSYNC_OPTIONS="--delete"
+# RSYNC_OPTIONS="--delete"
+
+# Use this option to run any command on the remote end after a successful copy
+# REMOTE_POST_COMMAND="make && make install"
View
@@ -1,11 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>contactEmailRot13</key>
+ <string>qnivq@byevx.qx</string>
+ <key>contactName</key>
+ <string>David Jack Wange Olrik</string>
<key>deleted</key>
<array>
<string>42868EF7-041F-48FE-B911-6FC74CA9A647</string>
</array>
+ <key>description</key>
+ <string>Syncronize project directory with remote server using rsync and ssh.</string>
<key>name</key>
<string>Synchronize remote directory [rsync+ssh]</string>
<key>ordering</key>

0 comments on commit 061234a

Please sign in to comment.