Skip to content

Instantly share code, notes, and snippets.

@Gipetto
Last active December 17, 2015 09:09
Show Gist options
  • Save Gipetto/5585319 to your computer and use it in GitHub Desktop.
Save Gipetto/5585319 to your computer and use it in GitHub Desktop.
Launch a new, clean and distinct instance of Google Chrome that cannot sync and does not do the first-run dance.
#! /bin/bash
set -e
[ -z $1 ] && dir='/tmp/foo' || dir=$1
chromedev="/Applications/Google Chrome Dev.app"
runChromeDev() {
(
"${chromedev}/Contents/MacOS/Google Chrome" \
--disable-sync \
--no-first-run \
--user-data-dir="${dir}" > /dev/null 2>&1
rm -r "${dir}"
) &
}
chromeDevFirstRun() {
echo "Performing ChromeDev first run"
echo "Copying 'Google Chrome.app' to 'Google Chrome Dev.app'"
cp -R "/Applications/Google Chrome.app" "${chromedev}"
local infoplist="${chromedev}/Contents/Info.plist"
local stringsfile="${chromedev}/Contents/Resources/en.lproj/InfoPlist.strings"
# update info.plist
echo "Updating 'Info.plist' to create unique instance of Chrome"
sed -i -e "s/<string>com.google.Chrome<\/string>/<string>com.google.ChromeDev<\/string>/" "${infoplist}"
sed -i -e "s/<string>Chrome<\/string>/<string>Chrome Dev<\/string>/" "${infoplist}"
# update InfoPlist.string for display names
echo "Updating 'InfoPlist.strings' to create a unique display name for this instance"
plutil -convert 'json' "${stringsfile}"
sed -i -b -e 's/"CFBundleDisplayName":"Google Chrome"/"CFBundleDisplayName":"Google Chrome Dev"/' "${stringsfile}"
sed -i -b -e 's/"CFBundleName":"Chrome"/"CFBundleName":"Chrome Dev"/' "${stringsfile}"
# uncomment this if you have problems with the display name not being what you expect
# plutil -convert 'binary1' "${stringsfile}"
}
if ! [ -d "${chromedev}" ]; then
chromeDevFirstRun
fi
runChromeDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment