Skip to content

Instantly share code, notes, and snippets.

@haegrr
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save haegrr/e9911dc5ecf92631e759 to your computer and use it in GitHub Desktop.

Select an option

Save haegrr/e9911dc5ecf92631e759 to your computer and use it in GitHub Desktop.
#!/bin/bash
sed_inplace() {
tmpfile=$(mktemp "$TMPDIR/unfuglify-textmate.XXXXXX")
cp "$2" "$tmpfile"
sed -E "$1" "$tmpfile" > "$2"
rm -f "$tmpfile"
}
if [ $# != 3 ]; then
echo "usage: $(basename $0) <source> <dest> <signing identity>" >&2
exit 1
fi
if ! command -v codesign >/dev/null; then
echo "codesign not in PATH, have you installed the Xcode command-line tools?"
exit 2
fi
source="$1/Contents/Resources"
dest="$2/Contents/Resources"
signing_identity="$3"
pushd "$source" > /dev/null
ls -1 *.icns | while read source_icon; do
dest_icon=$(find "$dest" -iname "$source_icon")
if [ -n "$dest_icon" ]; then
cp -v "$source_icon" "$dest_icon"
fi
done
cp -v TMDocument.icns "$dest/Blank.icns"
cp -v TMDocument.icns "$dest/CoffeeScript.icns"
cp -v JS.icns "$dest/JavaScript.icns"
cp -v TMDocument.icns "$dest/JSON.icns"
cp -v TMDocument.icns "$dest/Ragel.icns"
cp -v TM-Item.icns "$dest/TextMate Bundle Item.icns"
cp -v TMBundle.icns "$dest/TextMate Bundle.icns"
cp -v TM-Command.icns "$dest/TextMate Command.icns"
cp -v TM-Lang.icns "$dest/TextMate Grammar.icns"
cp -v TM-Macro.icns "$dest/TextMate Macro.icns"
cp -v TMPlugin.icns "$dest/TextMate Plugin.icns"
cp -v TM-Prefs.icns "$dest/TextMate Settings.icns"
cp -v TM-Snippet.icns "$dest/TextMate Snippet.icns"
cp -v TMTheme.icns "$dest/TextMate Theme.icns"
sed_inplace 's/background-image: url\("flower(@2x)?\.png"\);//' "$dest/css/stylesheet.css"
popd > /dev/null
codesign -s "$signing_identity" -f "$2"
touch "$2"
killall Dock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment