Skip to content

Instantly share code, notes, and snippets.

@aptonic
Last active November 1, 2017 02:50
Show Gist options
  • Save aptonic/5596450c90d74342f0f8 to your computer and use it in GitHub Desktop.
Save aptonic/5596450c90d74342f0f8 to your computer and use it in GitHub Desktop.
A script you can use in a TextMate 2 bundle to make it easier to update Dropzone 3 actions
#!/usr/bin/env bash
# This script requires ansi2html.sh to be copied to ~/Library/Application Support/TextMate/Managed/Bundles/Bundle Support.tmbundle/Support/shared/bin/
# You can download ansi2html.sh from http://www.pixelbeat.org/scripts/ansi2html.sh
# Change this to wherever you cloned the dropzone3-actions repo to
DROPZONE_3_ACTIONS_REPO_PATH=~/"Documents/Dropzone 3/dropzone3-actions"
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
parentdir="$(dirname "$TM_FILEPATH")"
bundle_name="$(basename "$parentdir")"
extension="${bundle_name##*.}"
if [ "$extension" != "dzbundle" ]; then
exit
fi
cd "$DROPZONE_3_ACTIONS_REPO_PATH"
echo "<strong>Updating dropzone3-actions repo...</strong><br>"
git pull origin master | ansi2html.sh 2>&1
# Remove old bundle
rm -rf "$bundle_name"
# Copy in this one
echo "<strong>Moving bundle into dropzone3-actions...</strong><br><br>"
cp -r "$parentdir" ./
git diff --color=always . | ansi2html.sh 2>&1
echo "<strong>^ Changes are shown above ^</strong><br>"
res=$(CocoaDialog inputbox --title "Commit Changes" --informative-text "Enter commit message:" --button1 "OK" --button2 "Cancel")
[[ $(head -n1 <<<"$res") == "2" ]] && exit_discard
res=$(tail -n1 <<<"$res")
git add -A | ansi2html.sh
git commit -m "$res" | ansi2html.sh
git push | ansi2html.sh 2>&1
echo "<br><strong>Bundle update complete</strong><br>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment