Anand Sudhanaboina

Launch Random Chrome Instances Faster

Multiple instances of Chrome can be spun by creating profiles. While working on my new Chrome extension pin tabs, I found a need to launch new chrome instances to test a few things. Problem with profiles is that Chrome saves them, i.e; you need to delete profiles which you don’t need later on, this might get messy if you have quite a many. Here’s a quick and simple way to launch and auto-kill chrome instances:

1
2
3
4
5
6
function launch-chrome-new-profile(){
  hash=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '')
  google-chrome --user-data-dir=/tmp/chrome-instances/$hash -no-first-run
  rm -rf /tmp/chrome-instances/$hash
  unset hash
}

launch-chrome-new-profile will launch a new chrome instance with data dir /tmp/chrome-instances/$hash with a random hash, once you close this instance the data dir will be auto-deleted.

Comments