Skip to content

Instantly share code, notes, and snippets.

@aculich
Created September 19, 2021 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aculich/8f614d68b4eca7dd07aed10d45e3aee8 to your computer and use it in GitHub Desktop.
Save aculich/8f614d68b4eca7dd07aed10d45e3aee8 to your computer and use it in GitHub Desktop.
Open a Chrome profile based on email-address from data in chrome://local-state/ JSON format
# To get a list of Chrome profiles in JSON format use this URL in your Chrome browser:
# chrome://local-state/
# Save the content to local-state.json and then:
cat local-state.json| jq '.profile.info_cache | to_entries | .[] | [{person:.value.gaia_given_name, label:.value.name, email:.value.user_name, profile:.key}]'
cat local-state.json| jq '.profile.info_cache | to_entries | .[] | select(.value.user_name=="aculich@berkeley.edu") | [{person:.value.gaia_given_name, label:.value.name, email:.value.user_name, profile:.key}]'
# jq-cheetsheet.md
# https://gist.github.com/olih/f7437fb6962fb3ee9fe95bda8d2c8fa4
# This outputs an array of objects with the Profile Name, Email, and Person
# along with the name of the Profile Directory as one of the values
# Then you can use it to find the corresponding Chrome profile directory
# based on the email address of the profile
open -n -a "Google Chrome" --args --profile-directory="Profile 1" --new-window
function cpr () {
CMD="cat local-state.json| jq '.profile.info_cache | to_entries | .[] | select(.value.user_name==\"$1\") | [{person:.value.gaia_given_name, label:.value.name, email:.value.user_name, profile:.key}] | .[].profile'"
profile=$(eval $CMD)
echo "Opening Chrome Profile: $profile"
CMD="open -n -a 'Google Chrome' --args --profile-directory=$profile --new-window"
eval $CMD
}
cpr aculich@berkeley.edu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment