Skip to content

Instantly share code, notes, and snippets.

@dburger
Created August 21, 2016 15:38
Show Gist options
  • Save dburger/c7273a4317e7a6c512531659960d32cb to your computer and use it in GitHub Desktop.
Save dburger/c7273a4317e7a6c512531659960d32cb to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if [[ $# -eq 0 ]]; then
exec google-chrome &
exit 0
elif [[ $1 == "incognito" ]]; then
exec google-chrome --incognito &
exit 0
else
for preffile in ~/.config/google-chrome/{Default*,Profile*}/Preferences; do
[[ -e "$preffile" ]] || continue;
profname=$(jq ".profile.name" "$preffile")
echo "Found profile $profname in $preffile."
if [[ "$profname" == "\"$1\"" ]]; then
shift
profdir=$(echo "$preffile" | sed -e 's|^.*google-chrome/\([^/]*\)/Preferences$|\1|')
echo "Going to launch profile $profname with profile directory $profdir."
exec google-chrome --profile-directory="$profdir" "$@" &
exit 0
fi
done
echo "Profile with name $1 not found!"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment