Skip to content

Instantly share code, notes, and snippets.

@fatso83
Last active October 4, 2016 10:15
Show Gist options
  • Save fatso83/2206c5020466393c0926d701f7f4808e to your computer and use it in GitHub Desktop.
Save fatso83/2206c5020466393c0926d701f7f4808e to your computer and use it in GitHub Desktop.
Launch a fresh Chrome browser instance each time. Very useful for profiling.
#!/bin/sh
# This is quite useful for front-enders, as it will launch a fresh
# Chrome instance with no loaded plugins or extensions that messes
# with your performance profiling or network debugging
#
# Install:
# install -m 555 ~/Downloads/chrome-fresh /usr/local/bin/
#
# As an Application, just open the OS X script editor and type
# do shell script "~/bin/chrome-fresh"
# Save as "chrome-fresh" or something like that. You can now open
# the program in Finder or Spotlight.
# gist: https://gist.github.com/fatso83/2206c5020466393c0926d701f7f4808e
CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
ARGS="$@"
# make a fresh user directory
TMP_USERDIR=$(mktemp -d);
# avoid the dialog on the first startup
touch "$TMP_USERDIR/First Run";
# start chrome using a fresh user directory
"$CHROME" --user-data-dir="$TMP_USERDIR" "$ARGS" &
chromePid=$!
sleep 0.5
# bring Chrome
osascript -e 'tell application "System Events"' -e "tell (first process whose its unix id is \"$chromePid\" ) to set frontmost to true" -e 'end tell'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment