macos 初始化环境配置

macos 初始化

安装brew和git

安装Homebrew

https://brew.sh/zh-cn/

https://git-scm.com/download/mac


# 从阿里云下载安装脚本并安装Homebrew

git clone https://mirrors.aliyun.com/homebrew/install.git brew-install/bin/bash brew-install/install.shrm -rf brew-install# 

也可从 GitHub 获取官方安装脚本安装 

Homebrew /bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/raw/master/install.sh)"

-----

# 永久替换

# bash 用户

echo 'export HOMEBREW_API_DOMAIN="https://mirrors.aliyun.com/homebrew-bottles/api"' >> ~/.bash_profile

echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/brew.git"' >> ~/.bash_profile

echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/homebrew-core.git"' >> ~/.bash_profile

echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.aliyun.com/homebrew/homebrew-bottles"' >> ~/.bash_profile

source ~/.bash_profile

brew update

---------

# zsh 用户

echo 'export HOMEBREW_API_DOMAIN="https://mirrors.aliyun.com/homebrew-bottles/api"' >> ~/.zshrc

echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/brew.git"' >> ~/.zshrc

echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/homebrew-core.git"' >> ~/.zshrc

echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.aliyun.com/homebrew/homebrew-bottles"' >> ~/.zshrc

source ~/.zshrc

brew update

--------------

恢复默认设置

unset HOMEBREW_BREW_GIT_REMOTE

git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew

unset HOMEBREW_API_DOMAIN

unset HOMEBREW_CORE_GIT_REMOTE

BREW_TAPS="$(BREW_TAPS="$(brew tap 2>/dev/null)"; echo -n "${BREW_TAPS//$'\n'/:}")"

for tap in core cask{,-fonts,-versions} command-not-found services; do

    if [[ ":${BREW_TAPS}:" == *":homebrew/${tap}:"* ]]; then

        brew tap --custom-remote "homebrew/${tap}" "https://github.com/Homebrew/homebrew-${tap}"

    fi

done

brew update


查看brew信息

brew config



安装iterm2

brew search iterm2

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容