Sam Watkins's answer above did not quite work for me, as I have Chromium [specifically version 90.0.4430.212 (Developer Build) built on Debian 10.9, running on Debian 10.9 (32-bit) ] instead of Google Chrome installed, I also had to make a couple of other changes. Credit to Sam's answer for the core functionality. Here's my adapted solution, generally copied from theirs, I note the changes I made afterwards.
This is for Linux. It uses jq. You may need to run chmod 777 ~/.config/chromium/Local\ State
once, before using the scripts.
The first argument is the profile name, the rest are passed along to the chromium command-line.
If only the profile name is given, it opens on their default home page.
If run without any arguments, it opens chromium offering a choice of known profiles. (But if chromium is already running it just effectively does nothing. Of course if it's already running you can just select another profile by clicking your profile's icon next to the address bar.)
Example usage:
chromium_profile "Profile Name" https://google.com/
chromium_profile
:
#!/bin/bash -eu
profile_name=$1; shift
local_state=~/.config/chromium/Local\ State
profile_key=`< "$local_state" jq -r '
.profile.info_cache | to_entries | .[] |
select(.value.name == "'"$profile_name"'") | .key'`
[ -n "$profile_key" ]
chromium --profile-directory="$profile_key" "$@"
We can list the keys and names of all the profiles like this:
chromium_profiles_list
:
< ~/.config/chromium/Local\ State \
jq -r '.profile.info_cache | to_entries | map(.key + ": " + .value.name) | .[]' |
sort -k1,1 -k2,2n
Specifically to adapt Sam's answer I had to
- change the paths from google-chrome to chromium. For other browsers based on chrome/chromium (e.g. vivaldi) a similar change would probably work. You can definitively find the path by running
find ~ -name Local\ State
- change permissions on my
~/.config/chromium/Local\ State
file to allow access - since only my user and root exist on the machine I just ran
chmod 777 ~/.config/chromium/Local\ State
- Although jq apparently installed fine, this part of Sam's code just returned empty strings for me:
env.profile_name
.For some reason the environment variable did not pass through. So I use some really horrible quoting to get the variable's value to be inserted directly into the jq command string instead.
user-data-dir
ectory" contains 1 or more "profile-directory
s". The first one beingDefault
, the second one (if existent)Profile 1
, thenProfile 2
(I assume) and so on. So the--profile-directory=Default
parameter is relative to the user data directory by default (i.e. unless it starts e.g. with a drive letter:C:\MyChromeUserData\Default
). Apart from the profiles, the user data directory contains little° useful data. When browsing the web on this topic, reckon with confusing inconsistent terminology for these 2 user/profile folder levels. // ° Footnote in next comment: