Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ashugaev/1ba212b87e3a2fe247edb46f88e018c2 to your computer and use it in GitHub Desktop.

Select an option

Save ashugaev/1ba212b87e3a2fe247edb46f88e018c2 to your computer and use it in GitHub Desktop.
Launch new instances of Google Chrome on OS X with isolated cache, cookies, user config and custom Timezone
#!/usr/bin/env bash
# fresh-chrome
#
# Use this script on OS X to launch a new instance of Google Chrome
# with its own empty cache, cookies, and user configuration.
#
# The first time you run this script, it will launch a new Google
# Chrome instance with a permanent user-data directory, which you can
# customize below. Perform any initial setup you want to keep on every
# new Chrome instance, such as adding bookmarks and extensions. Then
# quit this Chrome instance with Command-Q or by selecting "Quit" from
# the "Chrome" menu. (The red "close" button is not sufficient.)
#
# AFTER that, every time you run this script it will launch a new
# Google Chrome instance with a temporary user-data directory copied
# from the one you set up the first time you ran this script. Every
# new instance of Google Chrome launched by this script will be
# completely isolated from the others.
### Customize these
# Permanent directory to store the user-data directory of your 'fresh'
# Chrome configuration.
fresh_dir="$HOME/.fresh-chrome"
# Temporary directory in which to create new user-data directories for
# temporary Chrome instances.
tmp_dir="/tmp"
### Main script begins
set -e
timestamp=`date +%Y%m%d%H%M%S`
if [[ -e "$fresh_dir" ]]; then
user_dir="$tmp_dir/chrome-$timestamp-$RANDOM"
cp -r "$fresh_dir" "$user_dir"
exec open -na "Google Chrome" --args "--user-data-dir=$user_dir"
else
exec open -na "Google Chrome" --args "--user-data-dir=$fresh_dir"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment