terminal 终端
- item2,替换 mac 自带的终端。
- go2shell,用于直接在 Finder 文件夹中打开终端。
shell 命令工具
zsh
macos 从 Catalina 开始, 使用 zsh 替代 bash 用做默认的 shell 工具。
1 2 3 4 5 6 7 8 9
| # shell 切换 (bash -- zsh) $ chsh -s /bin/zsh $ chsh -s /bin/bash
# 查看 zsh 版本 $ zsh --version
# 升级 zsh $ brew install zsh zsh-completions
|
oh my zsh
Oh My Zsh 是一款基于 zsh 的命令行工具。
1 2
| # 安装 $ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
oh my zsh 的配置文件 ~/.zshrc, bash 的配置文件 ~/.bash_profile
brew 包管理
Homebrew
Homebrew 是一款包管理工具,用以简化macOS系统上的软件安装过程。
1 2 3 4 5 6 7 8 9 10 11 12 13
| # 原始安装(网络不稳定) /$ bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Gitee安装:(推荐 优点全面 缺点慢一点) /$ bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
# Gitee快速安装:(优点安装速度快 缺点update功能需要命令修复 ) /$ bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" speed
# Gitee卸载: /$ bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"
|
国内源
1、将 Homebrew 镜像切换到阿里云或腾讯云。
1 2 3 4 5 6 7 8
| # 替换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
|
2、配置 HOMEBREW_BOTTLE_DOMAIN 环境变量。
1 2 3 4 5 6 7
| # bash echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile
# zsh echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc source ~/.zshrc
|
3、恢复默认配置。
1 2 3 4 5 6 7 8
| # 重置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 # 应用生效 brew update
|
环境变量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| # Ant export ANT_HOME="/Users/UserName/Tools/Android/ant/apache-ant-1.9.16"
# Maven export MAVEN_HOME="/Users/UserName/Tools/Android/maven/apache-maven-3.8.4"
# Protoc export PROTOC_HOME="/Users/UserName/Tools/protoc3.5.1"
# Android SDK (多个命名) export ANDROID_HOME="/Users/UserName/Tools/Android/sdk" export ANDROID_ROOT="/Users/UserName/Tools/Android/sdk" export ANDROID_SDK_HOME="/Users/UserName/Tools/Android/sdk" export ANDROID_SDK_ROOT="/Users/UserName/Tools/Android/sdk"
# Android NDK (多个命名) export NDK_HOME="/Users/UserName/Tools/Android/ndk/android-ndk-r10e" export NDK_ROOT="/Users/UserName/Tools/Android/ndk/android-ndk-r10e" export ANDROID_NDK_HOME="/Users/UserName/Tools/Android/ndk/android-ndk-r10e" export ANDROID_NDK_ROOT="/Users/UserName/Tools/Android/ndk/android-ndk-r10e"
# Java SDK (JDK) export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home"
# CMake export CMAKE_HOME="/Applications/CMake.app/Contents/"
# XCode Developer export XCODE_DEVELOPER="/Applications/Xcode.app/Contents/Developer"
# HomeBrew Aliyun export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles
# 添加环境变量 export PATH=$PATH:$ANT_HOME/bin export PATH=$PATH:$CMAKE_HOME/bin export PATH=$PATH:$PROTOC_HOME/bin export PATH=$PATH:$MAVEN_HOME/bin
export PATH=$PATH:$JAVA_HOME export PATH=$PATH:$JAVA_HOME/bin export PATH=$PATH:$JAVA_HOME/jre/bin
export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/platform-tools export PATH=$PATH:$ANDROID_HOME/build-tools
export PATH=$PATH:$NDK_HOME export PATH=$PATH:$XCODE_DEVELOPER
|
binutil
macOS 上无 readelf 和 objdump 两个命令,可以安装 binutil 工具实现。安装完成后,需要将其添加到环境变量中。
1
| export BINUTIL_BIN="/usr/local/opt/binutils/bin"
|
参考资料
https://developer.aliyun.com/mirror/homebrew