Created
June 11, 2013 17:23
Shell script to launch google chrome under a profile with a given name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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