若是你使用慣了linux,你會對軟件包管理、命令行不能自拔。因爲mac的底層是類unix系統,也能夠配置向linux同樣好用。html
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
複製代碼
上面必須先有ruby以及其餘開發環境支持,建議安裝xcode後使用以上命令安裝。linux
安裝成功之後,使用man brew
查看命令幫助學習使用。man brew
的內容不少,我下面展現brew --help
nginx
(data) youdi@liangchangyoudeMacBook-Pro ~ brew --help
Example usage:
brew search [TEXT|/REGEX/]
brew (info|home|options) [FORMULA...]
brew install FORMULA...
brew update
brew upgrade [FORMULA...]
brew uninstall FORMULA...
brew list [FORMULA...]
Troubleshooting:
brew config
brew doctor
brew install -vd FORMULA
Developers:
brew create [URL [--no-fetch]]
brew edit [FORMULA...]
https://docs.brew.sh/Formula-Cookbook.html
Further help:
man brew
brew help [COMMAND]
brew home
複製代碼
下面詳細介紹具體的使用git
brew search [TEXT|/REGEX/]
這個是進行搜索軟件包,參數支持正則表達式,github
(data) youdi@liangchangyoudeMacBook-Pro ~ brew search nginx
==> Searching local taps...
nginx ✔
==> Searching taps on GitHub...
homebrew/nginx/accesskey-nginx-module homebrew/nginx/xsltproc-nginx-module homebrew/nginx/anti-ddos-nginx-module homebrew/nginx/set-misc-nginx-module
homebrew/nginx/ajp-nginx-module homebrew/nginx/geoip2-nginx-module homebrew/nginx/array-var-nginx-module homebrew/nginx/stream-lua-nginx-module
複製代碼
1. brew search, -S:
顯示出本地全部可用的包,不加參數,不會去線上去查詢,使用`brew search`或`brew -S`
2. brew search [--desc] (text|/text/):
獲取一個軟件的短描述
3. brew search (--debian|--fedora|--fink|--macports|--opensuse|--ubuntu) text:
獲取不一樣平臺上軟件的文檔信息
複製代碼
brew (info|home|options) [FORMULA…]
正則表達式
1.brew infojson
brew info formulaubuntu
顯示這個軟件的信息,後面能夠接的參數有 —github, —json=version等等xcode
2.brew home瀏覽器
經過瀏覽器打開軟件的主頁
3.brew options
顯示軟件包的options信息,安裝時的,默認的安裝信息
brew install FORMULA...
安裝軟件使用的命令,也是咱們使用最頻繁的。看看她的詳細參數:
brew install [--debug][--env=(std|super)] [--ignore-dependencies|--only-dependencies][--cc=compiler] [--build-from-source|--force-bottle][--devel|--HEAD] [--keep-tmp][--build-bottle] formula [options …]
先來介紹最簡單的使用
安裝
brew install elinks
複製代碼
Homebrew 會將軟件包安裝到獨立目錄,並將其文件軟連接至 /usr/local
。
$ cd /usr/local/Cellar
$ tree -L 3 elinks
elinks
└── 0.11.7_2
├── AUTHORS
├── COPYING
├── ChangeLog
├── INSTALL_RECEIPT.json
├── NEWS
├── README
├── TODO
├── bin
└── share
3 directories, 7 files
$ cd /usr/local/bin
$ ll elinks
lrwxr-xr-x 1 youdi admin 36B 10 15 15:32 elinks -> ../Cellar/elinks/0.11.7_2/bin/elinks
複製代碼
Homebrew 不會將文件安裝到它自己目錄以外,因此您可將 Homebrew 安裝到任意位置。
你可使用man brew
或brew install --help
查看具體一些參數的使用,都很簡單。
brew update
brew upgrade
brew updte
會自動升級軟件包和自身
brew outdate
查看過期的軟件包,會有升級的版本號
brew upgrade
升級全部能夠升級的
brew upgrade <formula>
升級具體的軟件包
brew upgrade <formula>
中止一些軟件包的更新和升級
brew unpin <formula>
將中止更新的軟件包設置爲容許
brew cleanup <formula>
將軟件包的舊版本記錄清理掉
brew cleanup
清理全部
brew cleanup -n
顯示清理的內容
brew --cahce
顯示緩存位置, 通常是在
~/Library/Caches/Homebrew
brew list
brew list —help
brew list, ls [--full-name]:
列出全部的安裝的軟件包,能夠接一些參數,相似ls
List all installed formulae. If --full-name is passed, print formulae
with fully-qualified names. If --full-name is not passed, any other
options (e.g. -t) are passed to ls which produces the actual output.
brew list, ls --unbrewed:
List all files in the Homebrew prefix not installed by Homebrew.
# diy方式安裝的軟件
brew list, ls [--versions [--multiple]] [--pinned] [formulae]:
List the installed files for formulae. Combined with --verbose, recursively
list the contents of all subdirectories in each formula's keg. If --versions is passed, show the version number for installed formulae, or only the specified formulae if formulae are given. With --multiple, only show formulae with multiple versions installed. If --pinned is passed, show the versions of pinned formulae, or only the specified (pinned) formulae if formulae are given. See also pin, unpin. 複製代碼
brew unisntall
這個命令也是使用比較頻繁的。
brew uninstall, rm, remove [--force][--ignore-dependencies]
rm,remove也是卸載命令 --force 強制卸載, 若是有依賴,也強制卸載 --ignore-dependencies 忽略依賴
brew services
brew services [-v|--verbose] [list | run | start | stop | restart | cleanup] [...]
brew services [-v|--verbose] [list | run | start | stop | restart | cleanup] [...]
Easily start and stop formulae via launchctl.
With -v or --verbose, print more detail.
Integrates Homebrew formulae with macOS' launchctl manager. Services can be added to either /Library/LaunchDaemons or ~/Library/LaunchAgents. Basically, items in /Library/LaunchDaemons are started at boot, while those in ~/Library/LaunchAgents are started at login. When started with sudo, it operates on /Library/LaunchDaemons; otherwise, it operates on ~/Library/LaunchAgents. On start the plist file is generated and written to a Tempfile, and then copied to the launch path (existing plists are overwritten). [sudo] brew services list List all running services for the current user (or root) [sudo] brew services run formula|--all Run the service formula without starting at login (or boot). [sudo] brew services start formula|--all Start the service formula immediately and register it to launch at login (or boot). [sudo] brew services stop formula|--all Stop the service formula immediately and unregister it from launching at login (or boot). [sudo] brew services restart formula|--all Stop (if necessary) and start the service immediately and register it to launch at login (or boot). [sudo] brew services cleanup Remove all unused services. 複製代碼
1. brew services list
打印出安裝的全部服務
2. brew services run service_name
運行某個服務,沒有運行,運行,運行的,重啓
3. brew services start| stop| restart formula|--all
開啓,關閉,重啓
另外,本身定義服務,記住/Library/LaunchDaemons, ~/Library/LaunchAgents, /Library/LaunchDaemons,修改對應文件。
複製代碼
homebrew內容不少,另外,擴展性和靈活性也很強大,若是感興趣,能夠去官網文檔 閱讀文檔學習。