Skip to content

Instantly share code, notes, and snippets.

@dburger
Created June 11, 2013 17:23
Show Gist options
  • Save dburger/5758845 to your computer and use it in GitHub Desktop.
Save dburger/5758845 to your computer and use it in GitHub Desktop.
Shell script to launch google chrome under a profile with a given name.
#!/usr/bin/env bash
if [ $# -eq 0 ]; then
exec google-chrome &
exit 0
else
for preffile in ~/.config/google-chrome/{Default,Profile*}/Preferences; do
# The profile name appears to always be the last "name:" in the json
# of the Preferences file. Yes, fragile, but appears to work for now.
profname=$(grep \"name\" "$preffile" | tail -1 | sed -e 's/.*"\([^"]*\)",\?$/\1/')
if [ "$1" == "$profname" ]; then
profdir=$(echo "$preffile" | sed -e 's|^.*google-chrome/\([^/]*\)/Preferences$|\1|')
echo "Going to launch with profile directory: $profdir"
exec google-chrome --profile-directory="$profdir" &
exit 0
fi
done
# didn't find that profile name
echo "Profile named $1 not found!"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment