[Mac] 使用 Homebrew Cask 安裝 Mac App
最近經過同事介紹,才發現原來 Homebrew 也可以用來安裝 Mac 上的 App~
名字叫做 Homebrew Cask,算是 Homebrew 的一個 extension。
正好我需要裝 HipChat,就拿來試試看吧~
Homebrew Cask GitHub documentation
1. 先安裝 Homebrew Cask
用 brew 先把 cask 安裝好:
brew install caskroom/cask/brew-cask
2. 用 Cask 搜尋 HipChat
平常如果直接用 brew search hipchat,會找到 Caskroom/cask/hipchat:
testuser@localhost ~ $ brew search hipchat
Caskroom/cask/hipchat
如果直接 brew install hipchat 或 brew install Caskroom/cask/hipchat 都是不行的~
得用 brew cask 的擴充命令才行,像是用 brew cask search:
testuser@localhost ~ $ brew cask search hipchat ==> Exact match hipchat
建議找到 App 之後,先用 brew cask info 確認一下有沒有附註說明,
因為有時候會需要多做一些事情:
testuser@localhost ~ $ brew cask info hipchat hipchat: latest hipchat https://www.hipchat.com/ Not installed https://github.com/caskroom/homebrew-cask/blob/master/Casks/hipchat.rb ==> Contents HipChat.app (app)
上例中的 HipChat 是沒有什麼附帶說明,安裝好就可以用了。
但像是 google-chrome 的話,就有附註說跟 1Password 這軟體間的衝突問題:
testuser@localhost ~ $ brew cask info google-chrome google-chrome: latest google-chrome https://www.google.com/chrome/ Not installed https://github.com/caskroom/homebrew-cask/blob/master/Casks/google-chrome.rb ==> Contents Google Chrome.app (app) ==> Caveats The Mac App Store version of 1Password will not work with a Homebrew-Cask-linked Google Chrome. To bypass this limitation, you need to either: + Move Google Chrome to your /Applications directory (the app itself, not a symlink). + Install 1Password from outside the Mac App Store (licenses should transfer automatically, but you should contact AgileBits about it).
3. 用 Cask 安裝 HipChat
執行 brew cask install 就能安裝 app 了:
testuser@localhost ~ $ brew cask install hipchat ==> Downloading https://www.hipchat.com/downloads/latest/mac ######################################################################## 100.0% ==> Symlinking App 'HipChat.app' to '/Users/testuser/Applications/HipChat.app' hipchat staged at '/opt/homebrew-cask/Caskroom/hipchat/latest' (792 files, 29M)
Cask 預設會把東西安裝在 /opt/homebrew-cask/Caskroom 目錄下面,
然後在 ~/Applications 下面建立一個 symbolic link 指到安裝好的 app:
testuser@localhost ~ $ ll /opt/homebrew-cask/Caskroom/ drwxr-xr-x 4 testuser staff 136 2 4 11:45 hipchat/ testuser@localhost ~ $ ll ~/Applications lrwxr-xr-x 1 testuser staff 54 2 4 11:45 HipChat.app@ -> /opt/homebrew-cask/Caskroom/hipchat/latest/HipChat.app
當然平常直接去網頁或 App Store 下載 Mac app 安裝也是一樣的,
不過用 Homebrew Cask 是可以省去一些搜尋、下載,
以及把 app 拉到 Applications 目錄的麻煩,值得一試囉~~^^