Skip to content

Instantly share code, notes, and snippets.

@lsd
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsd/efecf50f3ae96dcff5b6 to your computer and use it in GitHub Desktop.
Save lsd/efecf50f3ae96dcff5b6 to your computer and use it in GitHub Desktop.
Wrapper around `plutil` to quickly jump between xml1 and binary1 when editing plists (propert lists in resources, Xcode)
#!/bin/sh
#
# A script to make it easier to edit resources in mac.apps on the commandline
# Isam M 2015 <http://github.com/lsd/update-plist.sh>
# exit if pipeline (1+ cmd) fails
set -e
echo
echo "USAGE (default English): To open ScreenCapture.strings in SystemUIServer.app/C/R/English.lproj
echo "$ sudo update-plist.sh ScreenCapture
echo
# hardcode English ...
# LANGUAGE="$1"
RESOURCE="$2".strings
LANGUAGE="English"
RESOURCE="$1".strings
DIR="/System/Library/CoreServices/SystemUIServer.app/Contents/Resources/$LANGUAGE.lproj"
# cd in, validate resource, make backup
pushd "$DIR"
ls -l
echo
diff "$RESOURCE" "$RESOURCE" 2>/dev/null
BACK=~/".$RESOURCE.binary1.`date -j +%S%s`.back"
cp "$RESOURCE" "$BACK"
echo "Backed up resource $RESOURCE to $BACK"
# Convert to XML, open in vi, when done convert back to binary
sudo plutil -convert xml1 "$RESOURCE"
sudo vi "$RESOURCE"
sudo plutil -convert binary1 "$RESOURCE"
# Clean up
mv "$BACK" /tmp
popd
echo
echo "Restart SystemUIServer? (ctrl+c to cancel)" && read
killall SystemUIServer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment