xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

macOS 应用多开 Google Chrome 应用分身 All In One

macOS 应用多开 Google Chrome 应用分身 All In One

Google Chrome 浏览器副本

应用多开,应用场景

  1. 区分个人和办公环境, 一个 app 登录多个不同的环境,数据隔离
  2. 节约磁盘空间,避免安装多个 Chrome, 如 dev,beta, canary, enterprise 等
  3. 创建无插件的干净的测试环境
  4. 举一反三, Windows => macOS
  5. 技术分享,前端后端测试,保持环境一致性,避免出现不必要的环境问题,导致出现业务方互相扯皮的现象

macOS Chrome 应用分身

应用分身原理:创建不同的用户数据存放目录 --user-data-dir

# custom user data ✅
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/Users/xgqfrms-mm/Desktop/Custom_Chrome";

solutions

  1. shell script & alias

custom-chrome.sh

#!/bin/bash

# 执行 Chrome.app
# /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome ;

# custom user data ✅
# /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/Users/xgqfrms-mm/Desktop/Custom_Chrome";

# alias 不是可执行文件 ❌ Custom Google Chrome 
# /Applications/Google\ Chrome.app/Contents/MacOS/Custom\ Google\ Chrome --user-data-dir="/Users/xgqfrms-mm/Desktop/Custom_Chrome";

# /Users/xgqfrms-mm/Desktop/custom-chrome.sh
# chmod +x ./custom-chrome.sh 

# /Users/xgqfrms-mm/Desktop/Custom_Chrome
# mkdir Custom_Chrome

# /Users/xgqfrms-mm/Library/Google/
# /Users/xgqfrms-mm/Library/Application Support/Google
# /Users/xgqfrms-mm/Library/Caches/Google

# echo $USER
# whoami
# who

# cd /Users/$USER/Desktop

# custom user data ✅
# /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/Users/xgqfrms-mm/Desktop/Custom_Chrome";
# /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/Users/$computer\ name/Desktop/Custom_Chrome";
# echo $USER 🚀
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/Users/$USER/Desktop/Custom_Chrome";
# /Users/xgqfrms-mm/Desktop/custom-chrome.sh

.zshrc 配置文件

# macOS Chrome 应用分身/应用双开
# /Applications/Google Chrome.app/Contents/MacOS
# https://www.cnblogs.com/xgqfrms/p/16993756.html

# 可执行脚本
# /Users/xgqfrms-mm/Desktop/custom-chrome.sh
# 用户数据
# /Users/xgqfrms-mm/Desktop/Custom_Chrome
# alias 全局快捷方式 $ccapp
alias ccapp='/Users/xgqfrms-mm/Desktop/custom-chrome.sh'
# source ~/.zshrc


custom chrome app => ccapp

# 全局 alias
# custom chrome app => ccapp
$ ccapp


  1. custom chrome app

Automator Application workflow

// 
solution steps 截图

复制 Chrome .icns

修改 /Users/xgqfrms-mm/Desktop/Custom-Chrome.app/Contents/_CodeSignature/CodeResources

<key>Resources/app.icns</key>
<!-- <key>Resources/ApplicationStub.icns</key> -->

solution steps 截图

动态获取 $USER 主机名/用户名

solution steps 截图

fix: 分发复用 custom chrome app bugs

The application “Custom-Chrome.app” can’t be opened.

$ cd /Users/$USER/Desktop/Custom-Chrome.app/Contents/MacOS

$ chmod +x Automator\ Application\ Stub
solution steps 截图

“Custom-Chrome.app” is damaged and can’t be opened. You should move it to the Trash.

# $ sudo spctl --master-disable

$ xattr -cr /Users/$USER/Desktop/Custom-Chrome.app

solution steps 截图

Windows Chrome 应用分身

右键快捷链接,新建用户数据存放目录

https://www.cnblogs.com/xgqfrms/p/15348198.html

https://www.cnblogs.com/xgqfrms/p/9467482.html

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

how to run app alias in macOS terminal

https://wpbeaches.com/make-an-alias-in-bash-or-zsh-shell-in-macos-with-terminal/

https://macosx-faq.com/how-to-make-alias-with-terminal/

https://stackoverflow.com/questions/8967843/how-do-i-create-a-bash-alias

https://dev.to/stuartcreed/how-to-add-aliases-to-your-terminal-on-mac-os-53dl

https://dev.to/shoki/set-your-first-alias-command-in-mac-terminal-z-command-1m8l

如何把一个 Shell 脚本打包成一个 macOS App

$ tree
(app-name).app
├── Contents
│   └── MacOS
│   └── (app-name)
└── Icon

# demo
custom-chrome-app.app
├── Contents
│   └── macOS
│   └──custom-chrome-app
└── Icon

https://techtalkbook.com/create-mac-app-from-a-shell-script/

https://blog.csdn.net/julius_lee/article/details/104693979

https://codeantenna.com/a/5KZhhGEokh

https://juejin.cn/post/7123098435254747149

https://blog.csdn.net/saw471/article/details/104777938

https://juejin.cn/post/6844903893835448334

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs

Windows & Chrome 应用多开

https://www.cnblogs.com/xgqfrms/p/9467482.html

macOS & Chrome 应用多开

https://www.cnblogs.com/xgqfrms/p/16993756.html

Custom-Chrome.app

https://github.com/xgqfrms/GMS/tree/master/Chrome/macOS

https://github.com/xgqfrms/GMS/blob/master/Chrome/macOS/readme.md#custom-chromeapp

https://zzk.cnblogs.com/s?w=blog%3Axgqfrms Chrome 应用分身

https://www.zhihu.com/question/360558369



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-12-20 10:55  xgqfrms  阅读(1535)  评论(23编辑  收藏  举报