使用iCloud共享的配置文件快速配置新Mac電腦

使用iCloud共享的配置文件快速配置新Mac電腦

本文我們介紹如何利用iCloud共享的配置文件來快速配置一臺(tái)新的Mac電腦,以此實(shí)現(xiàn)多臺(tái)電腦分享同一套配置的目的。

Screen Shot 2019-05-19 at 12.53.27 AM.png

準(zhǔn)備工作

  • 需要Apple iCloud的支持
  • iCloud Drive中已經(jīng)存有以下軟件的配置文件或目錄

工具列表

設(shè)置iCloud

環(huán)境相關(guān)的配置文件我基本上都放在iCloud Drive中,使用iCloud的同步功能,配置文件可以保存在云端,也可以共享給多個(gè)Mac電腦使用。
登陸iCloud,并關(guān)閉iCloud Drive的 Optimise Mac Storage功能。然后我們等待所有的iCloud文件同步到新Mac上。

52DECAA0-1988-4179-9435-63B5C881B712.png

軟件的安裝

  1. 安裝Homebrew
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    安裝成功的驗(yàn)證命令:
brew -v
Homebrew 2.1.2
Homebrew/homebrew-core (git revision cf0a; last commit 2019-05-18)
Homebrew/homebrew-cask (git revision 0e4c0; last commit 2019-05-18)
  1. 使用Homebrew安裝基本的環(huán)境(brew安裝軟件可任選,我把我的所有HomeBrew軟件都羅列于此)

因?yàn)橛行┸浖枰止ぽ斎氘?dāng)前賬戶的密碼,建議一個(gè)個(gè)軟件安裝下去

xcode-select --install
brew install gcc
brew install libuv
brew install zsh zsh-completions autojump zsh-syntax-highlighting


brew cask install wireshark
brew install postgresql
brew tap theory/sqitch
brew install sqitch_pg
brew install sqitch --with-postgres-support
brew install wget
brew cask install visual-studio-code
brew cask install iterm2
brew cask install appcleaner
brew install caskroom/cask/brew-cask
# brew tap caskroom/versions
brew cask install sublime-text
brew tap caskroom/fonts
brew cask install font-inconsolata font-menlo-for-powerline font-meslo-for-powerline
brew install terraform
brew install packer
brew install ansible
brew cask install virtualbox
brew cask install vagrant
brew cask install vagrant-manager

brew cask install typora
brew cask install github
brew install autossh
brew install jq
brew install gnu-sed
brew install mysql
brew install pre-commit
brew install certbot
brew install tig

brew cask install dash
brew cask install shortcat
brew cask install google-cloud-sdk
brew cask install docker
brew cask install google-chrome
brew cask install firefox

brew cask install qlcolorcode qlstephen qlmarkdown quicklook-json webpquicklook suspicious-package quicklookase qlvideo

brew install sonar-scanner

brew cask install dash
brew cask install alfred

brew cask install vault # hashicorp vault
brew install kubernetes-helm

配置iterm2

  1. 第一次打開Iterm2,軟件會(huì)提示需要給Full Disk Access權(quán)限,請(qǐng)前往”Security & Privacy”中心進(jìn)行授權(quán)。
    iterm2.gif
  1. 從iCloud Drive中恢復(fù)(設(shè)置)默認(rèn)配置文件
    再次打開iTerm2,打開preferences定位到General. 找到頁面最底部的 “Load preferences from a custom folder or URL”. 選擇此選項(xiàng), 并設(shè)置 folder到 /Users/george/Library/Mobile Documents/com~apple~CloudDocs/Personal_Sync_in_iCloud/PrefConf/profiles/iterm2_custom_folder

每個(gè)人的配置文件路徑都是不一樣的,請(qǐng)按照實(shí)際情況來設(shè)置文件夾。

BF4ADD9E-5D87-48A3-B7E2-6E337120FC0F.png
  1. 選擇Profiles選項(xiàng)卡,點(diǎn)擊默認(rèn)的配置項(xiàng),找到Text配置項(xiàng),配置字體為11pt Menlo Regular for Powerline
    4D7BA4CE-8A0F-4B30-9259-124E62F5FDAC.png
  1. 重啟iTerm2,這樣我的配置文件就回來了,因?yàn)槲覀冊(cè)O(shè)置的是iCloud Drive文件夾作為配置文件夾,我們的所有改動(dòng)都會(huì)被保存到云端,而且也能共享給其他使用iCloud作為配置文件路徑的iTerm2


    33A84351-5637-41A8-BE76-23E99BC4D9AC.png

更多關(guān)于iTerm2的配置

https://gist.github.com/kevin-smets/8568070

問題排查

Open iTerm2, so a default com.googlecode.iterm2.plist file is created.
Quit iTerm2
Deleted all cached preferences for iterm2 by issuing defaults delete com.googlecode.iterm2
Copied the file to the new Mac in the correct location inside Preferences folder, so I had my old profiles and settings back
Read in the prefs file with defaults read -app iTerm
Open iTerm2 and was happy to have profiles and window arrangements on my new Mac

https://apple.stackexchange.com/questions/111534/iterm2-doesnt-read-com-googlecode-iterm2-plist

https://iterm2.com/documentation-dynamic-profiles.html

Set a powerline patched font as default.
https://github.com/powerline/fonts/blob/master/Meslo%20Slashed/Meslo%20LG%20M%20Regular%20for%20Powerline.ttf
Meslo (the one in the screenshot). Click "view raw" to download the font.

使用iCloud Drive的.profile.oh-my-zsh

我已經(jīng)有.profile.oh-my-zsh在我的iCloud Drive中,所以我只需要關(guān)聯(lián)這些配置文件即可

export XW_HOME_FULL_PATH="/Users/`whoami`"

echo "source $XW_HOME_FULL_PATH/Library/Mobile\ Documents/com\~apple\~CloudDocs/Personal_Sync_in_iCloud/PrefConf/profiles/.profile" > ~/.profile

echo "source $XW_HOME_FULL_PATH/Library/Mobile\ Documents/com\~apple\~CloudDocs/Personal_Sync_in_iCloud/PrefConf/profiles/.zshrc"   > ~/.zshrc

再次重啟iTerm2,我們的iTerm2環(huán)境就已經(jīng)配置好了


263598F0-4621-45E3-8E88-BB1760114AAA.png

配置Dash sync

General -> Set Up Syncing

Snippets -> Open

# For syncing
/Users/georgehe/Library/Mobile Documents/com~apple~CloudDocs/Personal_Sync_in_iCloud/PrefConf/Dash/
# For snippets
/Users/georgehe/Library/Mobile Documents/com~apple~CloudDocs/Personal_Sync_in_iCloud/PrefConf/Dash/snippets.dash
41BF9C7A-97EE-4E81-BEFF-FBD0DD2142FF.png

配置Alfred

  1. 恢復(fù)license信息(沒有買PowerPack請(qǐng)略過)
  2. Set preferences folder到iCloud Drive

問題

  • PATH里面不要不要有~,換成具體的path,path,使用export XW_HOME_FULL_PATH=“/Users/$(whoami)
  • 如果HomeBrew安裝失敗或者速度過慢,可以考慮使用代理來加速
    export all_proxy=<proxy_url:proxy_port>

云平臺(tái)開發(fā)運(yùn)維解決方案@george.sre

個(gè)人主頁:https://geekgoogle.com

GitHub: https://github.com/george-sre

Mail: george.sre@hotmail.com

簡書: georgesre - 簡書

歡迎交流~

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Mac 開發(fā)配置手冊(cè) 手冊(cè)內(nèi)容為「如何讓一部全新的 MacBook 快速完成開發(fā)環(huán)境配置」,主要面向 Web 開發(fā)...
    cuteximi_1995閱讀 3,098評(píng)論 0 6
  • 轉(zhuǎn)載:作者:田園里的蟋蟀出處:http://www.cnblogs.com/xishuai/ 之前一直使用 Mac...
    zcl418閱讀 796評(píng)論 0 10
  • 【本篇博客為自己查詢方便所做,如果您能從中受益,筆者會(huì)感到榮幸】 軟件和目錄結(jié)構(gòu)層面 ~/Library/Appl...
    清水蘆葦閱讀 3,617評(píng)論 3 4
  • 1. 安裝 iTerm2 下載地址:https://www.iterm2.com/downloads.html 下...
    MiracleJQ閱讀 3,869評(píng)論 0 1
  • 姓名:陳嬌琳 公司:寧波易之機(jī)械有限公司 【日精進(jìn)打卡第10天】 【知~學(xué)習(xí)】 ...
    A快樂存在閱讀 154評(píng)論 0 1

友情鏈接更多精彩內(nèi)容