Last active
May 27, 2017 19:24
-
-
Save henderea/57a83deb39785e3be0890418b5b85790 to your computer and use it in GitHub Desktop.
switch-epichrome-python.sh
This file contains 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 | |
function fail { | |
echo "Encountered error: $1" | |
exit 1 | |
} | |
if [ ! -s /usr/local/bin/brew ]; then | |
xcode-select --install | |
echo "Installing Homebrew" | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || fail "Homebrew failed to install" | |
fi | |
if [ ! -s /usr/local/bin/python ]; then | |
echo "Installing python with Homebrew" | |
/usr/local/bin/brew update || fail "Homebrew failed to update its list of available software" | |
/usr/local/bin/brew install python || fail "Homebrew failed to install python" | |
fi | |
pv=$(/usr/local/bin/python -V 2>&1 | awk '{ print $2; }') | |
if [[ "$pv" < "2.7.13" ]]; then | |
echo "Homebrew python version is ${pv}; upgrading to latest" | |
/usr/local/bin/brew update || fail "Homebrew failed to update its list of available software" | |
/usr/local/bin/brew upgrade python || fail "Homebrew failed to upgrade python to the latest version" | |
fi | |
pv=$(/usr/local/bin/python -V 2>&1 | awk '{ print $2; }') | |
if [[ "$pv" < "2.7.13" ]]; then | |
echo "Unable to upgrade Homebrew python to the proper version; exiting" | |
exit 1 | |
fi | |
echo " | |
Updating Epichrome files in /Applications/" | |
locate org.epichrome.helper-host.py | grep "/Applications" | awk '{ print "\""$0"\""; }' | xargs sed -i -- 's/\/usr\/bin\/python/\/usr\/local\/bin\/python/' | |
echo "Finished updating Epichrome files in /Applications/ | |
Here are the results:" | |
locate org.epichrome.helper-host.py | grep "/Applications" | awk '{ print "\""$0"\""; }' | xargs head -n 1 | |
echo " | |
Updating Epichrome files in existing apps" | |
sed -i -- 's/\/usr\/bin\/python/\/usr\/local\/bin\/python/' ~/Library/Application\ Support/Epichrome/Apps/*/NativeMessagingHosts/org.epichrome.helper-host.py | |
echo "Finished updating Epichrome files in existing apps | |
Here are the results:" | |
head -n 1 ~/Library/Application\ Support/Epichrome/Apps/*/NativeMessagingHosts/org.epichrome.helper-host.py | |
echo " | |
Operation complete. Please exit and reopen any Epichrome apps. | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment