手机指南针自制
An introduction to the popular package manager
热门软件包管理器简介
Homebrew is a great package manager. Originally created for macOS, it now runs on Linux and the Windows Subsystem for Linux, too.
Homebrew是一位出色的软件包管理器。 它最初是为macOS创建的,现在也可以在Linux和Linux的Windows子系统上运行。
Using it, you can install almost any CLI application you can think of, and even full GUI apps.
使用它,您几乎可以安装所有可以想到的CLI应用程序,甚至可以安装完整的GUI应用程序。
(How do you install Homebrew?)
On macOS, the command to install Homebrew is:
在macOS上,安装Homebrew的命令是:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
On Linux/Windows, see the instructions on the official website.
在Linux / Windows上, 请参阅官方网站上的说明 。
After the above command executes, you’ll have the brew
command available in the terminal:
执行以上命令后,您将在终端中使用brew
命令:
See? We have a list of sub-commands we can use: brew install
, brew upgrade
, brew uninstall
, and more.
看到? 我们有可以使用的子命令列表: brew install
, brew upgrade
, brew uninstall
brew install
等。
(Installing applications)
Use the brew install
command to install an application:
使用brew install
命令安装应用程序:
brew install <packagename>
For example, to install mysql, run:
例如,要安装mysql,请运行:
brew install mysql
The command has a lot of options available, and you can check them out
该命令有很多可用选项,您可以签出它们
You might never need any of those options - I very rarely use anything else than the default brew install <package>
.
您可能永远不需要这些选项-除了默认的brew install <package>
之外,我很少使用其他任何选项。
Sometimes packages (like the mysql
package I used in the example above) will install, but they will require some additional steps before you can run them.
有时会安装软件包(例如上面示例中使用的mysql
软件包),但是在运行它们之前,它们将需要一些额外的步骤。
If this is the case, those are typically highlighted to you at the end of the installation process. Make sure you read everything Homebrew prints to the console, to avoid headaches later.
如果是这种情况,通常会在安装过程结束时向您突出显示这些内容。 确保已将Homebrew打印的所有内容读到控制台,以免日后头痛。
(Where are packages installed?)
Packages installed using Homebrew are all installed in a specific folder.
使用Homebrew安装的软件包都安装在特定的文件夹中。
Typically it’s /usr/local/Cellar
.
通常是/usr/local/Cellar
。
If you don’t find this folder, run brew --prefix
to find the correct folder prefix. On my system, this command returned /usr/local
, the place where the Cellar
folder can be found.
如果找不到此文件夹,请运行brew --prefix
查找正确的文件夹前缀。 在我的系统上,此命令返回/usr/local
,可以在其中找到Cellar
文件夹。
In there, you’ll find the list of the packages you installed, each into its own folder:
在此处,您将找到已安装软件包的列表,每个软件包都位于其自己的文件夹中:
(Updating a package)
A single package can be upgraded using
单个软件包可以使用
brew upgrade <packagename>
(Updating Homebrew)
Homebrew itself needs to be updated from time to time. It will sometimes automatically updated when you run commands, but you can manually tell it to update by running
自制程序本身需要不时更新。 有时在您运行命令时会自动更新,但您可以通过运行手动告诉它进行更新
brew update
(Removing a package)
It’s very easy to install a new package. It’s also very easy to uninstall it.
安装新软件包非常容易。 卸载它也很容易。
Run:
跑:
brew uninstall <packagename>
Doing so, Homebrew will completely remove the package from the system.
这样做,Homebrew将完全从系统中删除软件包。
(Installing GUI apps)
One cool thing that Homebrew can do, in addition to installing CLI (command line) apps is the ability to install GUI apps.
除了安装CLI(命令行)应用程序外,Homebrew可以做的一件很酷的事情就是安装GUI应用程序的能力。
Using:
使用:
brew cask <appname>
You can install a GUI apps that you’d traditionally need to find the website, download the package, move to /Applications
.. now it’s a single command.
现在,您只需安装一个命令,即可安装传统上需要查找网站,下载软件包,移至/Applications
..所需的GUI应用程序。
For example:
例如:
brew cask firefox
You can find a list of all the apps you can install using this method on https://github.com/Homebrew/homebrew-cask/blob/master/Casks and you can search for a particular package using
您可以在https://github.com/Homebrew/homebrew-cask/blob/master/Casks上找到使用此方法可以安装的所有应用程序的列表,并且可以使用来搜索特定的软件包
brew search <name>
like this:
像这样:
brew search google-chrome
手机指南针自制