Created
April 3, 2019 17:51
-
-
Save Vinai/55e5357d1322e73edf9c56bc9fb4ae7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
current=$(php --version | head -1 | cut -f2 -d' ') | |
current=$(echo "${current%.*}") | |
php_head=$(brew info php | head -1 | cut -f3 -d' ') | |
from=$([ "${current}" = "${php_head%.*}" ] && echo "php" || echo "php@${current}") | |
to=$([ "${1}" = "${php_head%.*}" ] && echo "php" || echo "php@${1}") | |
echo "Switching from $from to $to" | |
brew services stop $from; brew unlink $from | |
brew link --force $to; brew services start $to | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment