Skip to content

Instantly share code, notes, and snippets.

@trq
Created November 30, 2012 02:21
Show Gist options
  • Save trq/4173383 to your computer and use it in GitHub Desktop.
Save trq/4173383 to your computer and use it in GitHub Desktop.
#!/bin/bash
RESTORE='\033[0m'
RED='\033[00;31m'
GREEN='\033[00;32m'
brew_php_link=$(ls -l /usr/local/bin/php | grep -Eo 'php([0-9]{1,2})')
current_php_version=$(php --version | head -n1 | awk '{print $2}')
if [ $brew_php_link == 'php54' ] ; then
brew unlink php53 > /dev/null 2>&1
brew unlink php54 > /dev/null 2>&1
brew link php53 > /dev/null 2>&1
else
brew unlink php53 > /dev/null 2>&1
brew unlink php54 > /dev/null 2>&1
brew link php54 > /dev/null 2>&1
fi
new_php_version=$(php --version | head -n1 | awk '{print $2}')
echo -e "${RED}PHP ${current_php_version}${RESTORE} > ${GREEN}PHP ${new_php_version}${RESTORE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment