美文网首页
macos 初始化环境配置

macos 初始化环境配置

作者: ljh_10e3 | 来源:发表于2024-05-03 16:08 被阅读0次

    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

    相关文章

      网友评论

          本文标题:macos 初始化环境配置

          本文链接:https://www.haomeiwen.com/subject/hupcfjtx.html