在Mac OS X Yosemite下,这些答案都无法全面地为我工作。这是我的解决方案,为您提供了多个实例,实例的扩展坞启动菜单以及每个实例的不同图标。运行脚本时,它将自动浏览所有配置文件,然后告诉您下一步该怎么做。
#!/bin/bash
# cdi.sh - Make chrome profiles behave like multiple browsers on Mac OS X
# (Tested on Yoshmite). Make profiles work like seperate applications
# - esp. useful if you want to easily switch between different browsers
# in different virtual desktops / workspaces, or don't want work
# windows mixed in with home windows in the "Window" menu, or want to
# be able to easily see what processes are with a certain profile in
# chrome task manager, or be able to eaisly quit one profile with
# multiple windows open and start where you left of later.
set -e
cd /Users/$USER/Library/Application\ Support/Google/Chrome
CDI="cdi-chrome-multiple-profile-instances-in-dock-with-different-icons.d"
APPLESCRIPTS="$CDI/Applescript-Sources"
LAUNCHERS="$CDI/Chrome-Launchers"
RUNTIMES="$CDI/Chrome-Runtimes"
test -d $CDI || mkdir $CDI
test -d $APPLESCRIPTS || mkdir $APPLESCRIPTS
test -d $LAUNCHERS || mkdir $LAUNCHERS
test -d $RUNTIMES || mkdir $RUNTIMES
grep '"username"' Profile*/Preferences Default/Preferences | grep -v ' ' | awk -F : '{print $1";"$3}' | sed 's:/Preferences::g' | sed 's:\@:-at-:g' | sed 's/;\ /;/g' > $CDI/profiles.txt
# Like: Profile 1;"webmaster-at-example.org"
echo "Be patient, this involves copying a lot of data..."
while read PROFILE; do
DIR="$(echo $PROFILE | awk -F\; '{print $1}')"
# Like: DIR='Profile 1'
echo "Working on profile: $DIR"
LINK="$(echo $PROFILE | awk -F\; '{print $2}' | sed 's/\ /\-/g' | sed 's/"//g' | sed 's/^/cdi-profile-/g')"
# Like: cdi-profile-webmaster-at-example.org
APP="$(echo $LINK | sed 's/^cdi-profile-//g' | sed 's/$/-DO-NOT-RUN-DIRECTLY-JUST-USE-FOR-CHANGING-ICON-cdi\.app/g')"
# Like: webmaster-at-example.org-DO-NOT-RUN-DIRECTLY-JUST-USE-FOR-CHANGING-ICON-cdi.app
SHIM="$(echo $LINK | sed 's/^cdi-profile-//g' | sed 's/$/\.app/g')"
# Like: webmaster-at-example.org.app
TXT="$APPLESCRIPTS/$(echo $LINK | sed 's:^cdi-profile-:chrome-:g' | sed 's/$/\.txt/g')"
# Like:
# cdi-chrome-multiple-profile-instances-in-dock-with-different-icons.d
# /Applescript-Sources/chrome-webmaster-at-example.org.txt
test -L "$LINK" || ln -s "$DIR" "$LINK"
cd "$LINK"
test -L Default || ln -s . Default
cd /Users/$USER/Library/Application\ Support/Google/Chrome
test -d "$RUNTIMES/$APP" || cp -R /Applications/Google\ Chrome.app "$RUNTIMES/$APP"
## This section disabled because enabling it makes automatic profile login not work.
## There is a chance someone who knows more about chrome will help at some point; see:
## https://code.google.com/p/chromium/issues/detail?id=460787
## https://groups.google.com/a/chromium.org/forum/#!topic/chromium-discuss/0HEeMuh8WqA
## https://github.com/lhl/chrome-ssb-osx
# Change Bundle ID so desktop assignation works. Not sure if this will survive updates.
# CFBundleIdentifier must contain only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.) characters.
# (Based on fiddling around there also seems to be a length limit.)
#UUID="$(echo $APP | md5sum | awk '{print $1}' | tr [0-9] [A-Z] | cut -c 1-4,29-32)"
#plutil -replace CFBundleIdentifier -string "cdi.$UUID" -- "$RUNTIMES/$APP/Contents/Info.plist"
#plutil -replace CFBundleName -string "$UUID" -- "$RUNTIMES/$APP/Contents/Info.plist"
#plutil -replace CFBundleDisplayName -string "$UUID" -- "$RUNTIMES/$APP/Contents/Info.plist"
#plutil -replace KSProductID -string "cdi.$UUID" -- "$RUNTIMES/$APP/Contents/Info.plist"
# To check: defaults read ~/Library/Preferences/com.apple.spaces.plist app-bindings
echo "on run" > $TXT
echo -n "do shell script " >> $TXT
echo -n '"' >> $TXT
echo -n "/Users/$USER/Library/Application\\\\ Support/Google/Chrome/$RUNTIMES/$APP/Contents/MacOS/Google\\\\ Chrome --user-data-dir=/Users/$USER/Library/Application\\\\ Support/Google/Chrome/$LINK" >> $TXT
echo ' > /dev/null 2>&1 &"' >> $TXT
echo "quit" >> $TXT
echo "end run" >> $TXT
test -d "$LAUNCHERS/$SHIM" || osacompile -o "$LAUNCHERS/$SHIM" $TXT
done < $CDI/profiles.txt
echo
echo 'Done with automated portion. Now you should manually:'
echo
echo '1. Add (identical) icons of your choice to each pair of profile Launchers'
echo ' / Runtimes in the folder ~/Library/Application Support/Google/Chrome/'
echo ' cdi-chrome-multiple-profile-instances-in-dock-with-different-icons.d'
echo ' (google for numerous guides on how to change mac os x app icons)'
echo
echo '2. From the finder, drag the "Chrome-Launchers" folder to the stacks area'
echo ' of the dock. Right click on the stack and select "List" for easy viewing.'
echo ' Also select "Display as Folder" and give the folder a nice icon.'
echo
echo '3. BE SURE to only open Chrome via this stack. DO NOT pin the app-area'
echo ' Chrome icon(s) to the app area of the dock! DO NOT run "normal" Chrome!'
echo
echo 'The only exception to (3) is if you need to add a new profile. In that case,'
echo 'close all instances, then open the "normal" Chrome, add profile, close, and'
echo 'then run this script again.'
echo
echo 'Note: when you launch first time you will get "Welcome to Google Chrome"'
echo ' dialog box. This is normal; do not worry. It will ask if you want'
echo ' to set Chrome as default; this applies to that instance of chrome.'
echo ' Choosy - http://www.choosyosx.com/ - works great with this!'
echo
对于图标,您可以使用任何PNG(或可能的许多其他格式)。
您可能已经习惯使用的Chrome头像在“〜/ Library / Application Support / Google / Chrome / Avatars”下-avatar_ninja.png等。
或自己制作,或使用众多图标网站之一-我喜欢Easyicon。
这似乎也很有用- 如何在Chrome中取回头像以更轻松地切换用户个人资料 -使打开的窗口更容易快速识别(未试用)。
尚无法解决的一件事就是能够将不同的用户个人资料Chrome实例分配给特定的桌面。这是因为如果更改了用于执行此操作的属性,则在浏览器启动时,浏览器将不再能够自动登录该配置文件。我已经在这个问题上发表了论坛帖子和错误报告;对于特定于站点的浏览器来说,这也是一个问题,因此chrome-ssb-osx项目可能会在某个时候使它正常工作。我没有10个信誉点,需要在此处的帖子中包含2个以上的链接(帮助!:-),因此您必须在上面的脚本中查看指向这些内容的链接(“已禁用此部分”部分) )。
Settings->Users
询问“为此用户创建桌面快捷方式”,如果您单击“是”,它会创建一个快捷方式,即Chrome图标,该用户的Chrome配置文件图标覆盖在右下角。当应用程序运行时,每个配置文件在任务栏中都有其自己的图标。我之所以提出这个建议,是因为我希望他们最终将这一功能引入macOS版本。