macos system software management tools Homebrew

Homebrew use refers to the North

For accustomed to using the command to complete all of the programmers, software install such a trivial matter, nature is able to solve command, would not have a graphical interface to select. But in Linux, we have  yum, apt, dnf, pkgand other commands to complete the installation of the software, macOS but did not provide a user-friendly package manager to help us better use macOS.

Fortunately, although the official did not provide, but we can use the Homebrew this artifact to do similar things, like Homebrew's Slogan: "The missing package manager for macOS (or Linux)"

Homebrew

Homebrew developed by the developer Max Howell, and based on the BSD open-source, it is a very convenient package management tool. In the early days, only macOS the Homebrew version, follow-up with the increase in users, Homebrew also offers Linux versions use the same Homebrew help developers to configure the Linux environment.

Some of the core concepts Homebrew

Prior to the formal introduction of the use of Homebrew, let me introduce you to some of the core concepts of Homebrew, to understand these concepts can help you better to use Homebrew.

vocabulary meaning
formula (e) Installation package description files, formulae plural
cellar After installing the directory where
keg Specific directory where a package, keg cellar is a subdirectory
bottle Pre-compiled packages do not need to compile the source code download site, the speed will be much faster; most of the official repository of packages are installed by way of bottle
tap Download the source, analogous to the Package Manager repository under Linux
cask Installing an expansion macOS native application, you can also be understood as the application has a graphical interface.
bundle Dependent extension described Homebrew

One of the most critical is the tap, cask, we will be frequently used in the follow-up.

Homebrew common operations

Install Homebrew

Before using Homebrew, first of all we need to complete the installation of the Homebrew. Homebrew installation work is very simple, just to execute code, it can automatically start the installation process, to follow the prompts.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

install software

When you have completed the Homebrew, Homebrew you can use to complete the installation of the software, install the software when the command line is very simple, only need to perform  brew install [软件名] to install the software, for example, we want to install wget, you only need to perform  brew install wget on it a.

Search software

Many times, we do not know whether they want software, or say what specific name, this time you have two ways to complete the search

1. Use the search command

At the command line, you can use directly  brew search [关键词] to search

Command line search software

Enter the keyword you want to search to get the results.

When searching should follow rather less word, typo principle can not be searched.

2. Use Web Search

In addition to using the command line outside of search, you can use the web client search tool to assist your search. In the Homebrew official website, you can find links to formulae, or direct access https://formulae.brew.sh/ to search. You only need to enter the command you want to search in the input box interface, and then there will be corresponding candidate command

Search software

Select where you want to use that, it will click into the software's introduction page

View Software

You can see specific information Homebrew software is.

View package has been installed

If you want to see which packages you have installed, you can execute  brew list a command to view all the software you have installed.

View all software

Update an already installed package

We installed the software does not automatically update, so we can according to their needs, batch updating software, or update a single software.

你可以先使用 brew outdated 来查看所有有更新版本的软件。

Check the software needs to be updated

然后使用 brew upgrade 来更新所有的软件,或者是使用 brew upgrade [软件名]来更新单个软件。

卸载某个已经安装的包

如果你想要卸载某个包,你可以执行 brew uninstall [软件名] 来卸载一个特定的软件,比如卸载 wget 是这样的。

Uninstall a package has been installed

查看包的信息

如果你想要查看某个特定软件的信息,你可以执行命令 brew info [软件名] 来查看该软件的详情。

View packet

清理软件的旧版

Homebrew 用久了,会有一些历史版本的软件遗留在系统里,这个时候,你可以使用 brew cleanup 命令来清理系统中所有软件的历史版本,或者可以使用 brew cleanup [软件名]来清理特定软件的旧版。

Cleaning software legacy

管理后台软件

诸如 Nginx、MySQL 等软件,都是有一些服务端软件在后台运行,如果你希望对这些软件进行管理,可以使用 brew services 命令来进行管理

  • brew services list: 查看所有服务
  • brew services run [服务名]: 单次运行某个服务
  • brew services start [服务名]: 运行某个服务,并设置开机自动运行。
  • brew services stop [服务名]:停止某个服务
  • brew services restart:重启某个服务。
Software management background

检查 Hombrew 环境

如果你的 Hombrew 没有办法正常的工作,你可以执行 brew doctor 来开启 Homebrew 自带的检查,从而确认有哪些问题,并进行修复。

Check the Hombrew environment

更新 Homebrew

Homebrew 经常会在执行命令的时候触发更新,不过如果你想要主动检查更新,可以执行 brew update 来唤起 Homebrew 的更新。

添加一个新的 tap

homebrew 官方在安装的时候会有一些 tap 但是在使用时,依然会需要安装一些特殊的 tap ,这个时候,我们就要用到 tap 的命令来添加新的 tap.

在添加 tap 时,输入命令 brew tap [user/repo] ,就可以完成添加 tap 了

常用 tap

在使用 homebrew 时,我们一般会添加几个常用的 tap,来确保我们有足够的软件来安装。

1. Caskroom

Caskroom 是 Homebrew 下一个非常出名的 tap ,有了 caskroom,我们就可以安装一些有图形化界面的软件了,比如 VSCode、Typora 等软件。

使用起来也非常简单,最新版 Homebrew 中,你可以直接使用 brew cask install [软件名] 来安装特定的软件,homebrew 会自动安装 Caskroom。

2. homebrew-cask-fonts

程序员难免要安装一些代码字体,这样才能更好的写代码,Homebrew 也提供了方便我们安装字体的 tap。

在使用时,你需要先添加对应的 tap ,然后执行安装即可了,比如我们要安装 source code pro ,只需要执行如下命令。

brew tap homebrew/cask-fonts
brew cask install font-source-code-pro

使用技巧

切换国内的镜像源

Homebrew 默认使用的是国外的源,在下载时速度可能会比较慢。好在国内的清华大学和中科大提供了 Homebrew 的镜像源,我们可以很轻松的切换源,从而提升我们的下载速度。

使用中科大的镜像

执行如下命令,即可切换为中科大的镜像

cd "$(brew --repo)"
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git

使用清华大学的镜像

执行如下命令,即可切换为清华大学的镜像

git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

使用 Brewfile 完成环境迁移

设备永久了,我们的电脑中会有大量的软件,如果你需要迁移环境,重新安装会是一个大麻烦,好在 Homebrew 本身为我们提供了一个非常好用的环境迁移的工具 —— Homebrew Bundle

你首先需要在之前的电脑中执行 brew bundle dump 来完成当前环境的导出,导出完成后,你会得到一个 Brewfile

然后将 Brewfile 复制到新的电脑中,并执行 brew bundle 来开始安装的过程。

使用网页搜索 Caskroom 的软件

Brew Caskroom does not provide command search, but we can make use of some sites to search, an official Caskrrom Homebrew page: https: //formulae.brew.sh/cask/

In this page, you can see all the indexed page, enter the corresponding command line software can be installed.

You can also visit http://macappstore.org/, enter the software you want to install on your site, click search, pop-up page, you can view the installation guide.

Supporting software

In addition to the command line, there are two software can help us make better use of Homebrew, they are Cakebrew and launchrocket.

Cakebrew

Cakebrew Homebrew is the GUI Manager, Cakebrew, you can see all the currently installed software, and other software that can perform the upgrade and other operations in Caskbrew in.

You only need to perform  brew cask install cakebrew to complete Cakebrew installation.

After installation is complete, open it in the LaunchPad.

launchrocket

launchrocket Homebrew can be used to manage the installation of the service, when in use, you need to add the corresponding tap, and then install the software.

brew tap jimbojsb/launchrocket
brew cask install launchrocket

After installation is complete, open it in the LaunchPad

Guess you like

Origin www.cnblogs.com/yecao8888/p/12154461.html