Mac配置

mac的brew配置以及终端代理

替换Homebrew镜像源

原文链接

  1. bash终端配置
  • 替换brew.git:
    cd "$(brew --repo)"
    git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
  • 替换homebrew-core.git:
    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
  • 应用生效
    brew update
  • 替换homebrew-bottles:
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
    source ~/.bash_profile
  1. Zsh 终端配置

    # 替换brew.git:
    cd "$(brew --repo)"
    git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
    # 替换homebrew-core.git:
    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
    # 应用生效
    brew update
    # 替换homebrew-bottles:
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
    source ~/.zshrc
  2. 恢复默认配置

  • 首先执行下述命令:
    # 重置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
    
  • 然后删掉 HOMEBREW_BOTTLE_DOMAIN 环境变量,将你终端文件
    ~/.bash_profile
    或者
    ~/.zshrc
    HOMEBREW_BOTTLE_DOMAIN
    行删掉, 并执行
    source ~/.bash_profile
    或者
    source ~/.zshrc

终端走代理

  • 临时的方式,影响最小
    export http_proxy=http://proxyAddress:port
    e.g.
    export http_proxy="http://127.0.0.1:1087"
    export https_proxy="http://127.0.0.1:1087"