0%
Theme NexT works best with JavaScript enabled
查看shell类型 1 2 3 echo $SHELL bash: /bin/bash zsh: /bin/zsh
切换 shell类型
1 2 3 4 5 # 切换到bash chsh -s /bin/bash #切换到zsh chsh -s /bin/zsh
环境变量设置 bash shell 环境变量设置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 vim ~/.bash_profile # Setting PATH for Python 3.7 # The original version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}" export PATH export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles # Created by `pipx` on 2021-09-27 01:26:42 export PATH="$PATH:/Users/atx/.local/bin" export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:. PATH=$PATH:/usr/local/mysql/bin export ANDROID_HOME=/usr/local/share/android-sdk export ANDROID_SDK_ROOT=/usr/local/share/android-sdk export PATH=${PATH}:${ANDROID_HOME}/tools export PATH=${PATH}:${ANDROID_HOME}/platform-tools
zsh shell 环境变量设置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 vim ~/.zshrc export PATH="$PATH:$HOME/.rvm/bin" export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles export NVM_DIR="$HOME/.nvm" [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home export PATH=$JAVA_HOME/bin:$PATH export PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin:$PATH export ANDROID_HOME=/usr/local/Caskroom/33.0.1 export PATH=$ANDROID_HOME/platform-tools:$PATH export PATH=/Users/mac/node_modules/.bin:$PATH export PATH=/usr/local/mysql/bin:$PATH
zsh 配置文件说明
zshenv:.zshenv总是被读取,所以通常把$PATH, $EDITOR等变量写在这里,这样无论是在shell交互,或者运行程序都会读取此文件
.zshrc:zshrc主要用在交互shell,所以主要是为shell服务的,比如对shell做的一些个性化设置都可以在这里写入
.zlogin:.zlogin在login shell的时候读取,所以比如X系统启动的时候会读取此文件,所以不会再运行中重复读取
.zprofile: .zprofile是给ksh用户的一个.zlogin的替代品,所以我们如果使用了.zlogin就不必再关心此文件
.zlogout: .zlogout这个就很好理解了, 退出终端的时候读取,用于做一些清理工作,一般我们也用不上
配置文件加载顺序 1 .zshenv → [.zprofile if login] → [.zshrc if interactive] → [.zlogin if login] → [.zlogout sometimes].
参考资料