想在.zshrc 里面实现版本切换
背景:历史代码需要老版本支持
环境: macOS
目前:现在要切换版本要三步,不是很优雅:
1、php71 || php56
2、修改对应 PHP 版本 export
3、source .zshrc
问题:想一步搞定,这个怎么在.zshrc 里面执行(看这里)
php_version="php -v|grep 'PHP 7'" 这句貌似没值
#php version change
alias php56="brew services stop [email protected] && brew services start [email protected]"
alias php71="brew services stop [email protected] && brew services start [email protected]"
php_version="php -v|grep 'PHP 7'"
if [[ $php_version == "" ]]; then
export PHP_56_HOME_BIN="/usr/local/opt/[email protected]/bin:$PATH"
export PHP_56_HOME_SBIN="/usr/local/opt/[email protected]/sbin:$PATH"
else
export PHP_71_HOME_BIN="/usr/local/opt/[email protected]/bin:$PATH"
export PHP_71_HOME_SBIN="/usr/local/opt/[email protected]/sbin:$PATH"
fi