Homebrew的安装和使用

Homebrew是什么

  • Homebrew是一款Mac
    OS平台下的软件包管理工具,拥有安装卸载更新查看搜索等很多实用的功能。简单的一条指令,就可以实现包管理,无需关心各种依赖和文件路径的情况,十分方便快捷。

Homebrew的安装和卸载

  1. 在命令行中执行以下命令
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. 卸载Homebrew
      $ cd `brew --prefix`
      $ rm -rf Cellar
      $ brew prune
      $ rm `git ls-files`
      $ rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
      $ rm -rf .git
      $ rm -rf ~/Library/Caches/Homebrew
    
    

Homebrew常用命令

  1. 安装软件
    	brew install 软件名称
    
  2. 卸载软件
    	brew uninstall 软件名称
    
  3. 查询软件
    	brew search 软件名称
    
  4. 列出所有已安装的软件
    	brew list
    
  5. 更新Homebrew
    	brew update
    
  6. 更新软件
    	brew upgrade 软件名
    
  7. 查看软件信息
    	brew info 软件名称
    
  8. 查看软件的依赖包
    	brew deps
    
  9. 查看Homebrew是否正常运行
    	brew doctor
    
  10. 查看Homebrew版本信息
    	brew -v
    

更新Homebrew数据源

	# 替换brew.git:
	$ cd "$(brew --repo)"
	# 中国科大:
	$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
	# 清华大学:
	$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
	
	# 替换homebrew-core.git:
	$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
	# 中国科大:
	$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
	# 清华大学:
	$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
	
	# 替换homebrew-bottles:
	# 中国科大:
	$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
	$ source ~/.bash_profile
	# 清华大学:
	$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
	$ source ~/.bash_profile
	
	# 应用生效:
	$ brew update

重置Homebrew数据源

	# 重置brew.git:
	$ cd "$(brew --repo)"
	$ git remote set-url origin https://github.com/Homebrew/brew.git
	
	# 重置homebrew-core.git:
	$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
	$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值