背景:在剛拿到mac 的時候,使用了默認的bash,由於工作需要在電腦上安裝了maven,在~/.bash_profile 文件中添加了maven的配置如下
$ cat ~/.bash_profile
export M2_HOME=/Users/yingmi/software/apache-maven-3.6.0
export PATH=$PATH:$M2_HOME/bin
平時通過Terminal 使用 maven clean install來構建maven項目用的也很順手。
前不久,看到了oh my zsh,相比於默認的bash 真的叫高端大氣上檔次(具體怎么安裝oh my zsh 大家可以到官網查看安裝說明)。
安裝之后的某一天
$ mvn clean
zsh: command not found: mvn
因為安裝zsh,~/.bash_profile就不會被執行,解決辦法有兩種:
vim ~/.zshrc 將你要配置到環境變量配置到該文件中即可
vim ~/.zshrc 將 source ~/.bash_profile 添加到末尾,這樣~/.bash_profile配置的環境變量同樣有效
然后 source ~/.zshrc即可