dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 9e0172fa9c7ddb77cd3255f10ce778634b08f187
parent 29aa67529f0bdfc8baadca3953e16cfdbaca88b8
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Wed, 23 May 2018 16:08:41 +0200

Major brewmaster update => updatemaster

Moved brewmaster out of the commonprofile and made it its own script.
Also added updates to pip, pip3, mac app store (mas), and npm.
Separated brew and brew cask upgrades, they can now be upgraded separately.

Diffstat:
Abin/updatemaster | 108+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcommonprofile | 72+++++++++++++++++++++---------------------------------------------------
2 files changed, 129 insertions(+), 51 deletions(-)

diff --git a/bin/updatemaster b/bin/updatemaster @@ -0,0 +1,108 @@ +#!/usr/local/bin/zsh + +### SET UP NOTIFY ### +if ! command -v notify &> /dev/null; then + if command -v terminal-notifier &> /dev/null; then + notify() { terminal-notifier -title "$1" -message "$2" -activate com.googlecode.iterm2; } + else + notify() { echo '\a'; } + fi +fi + +### HOMEBREW ### +if command -v brew &> /dev/null; then + echo "Beginning Homebrew update/upgrade." + brew update; + brew update > /dev/null; + outdated="$(brew outdated)" + outdated_c="$(brew cask outdated --greedy)" + + # Potentially upgrade programs + if [ ${#outdated} = 1 ]; then + echo "No programs to update." + else + echo "\nTo update:\n" + brew outdated; + notify "Brew: Finished reading updates" "Click to view outdated packages." + echo -n "Continue? [Y/n]" + read -sqn CONF + + if [ "$CONF" != "y" ]; then + echo "\nCancelled brew upgrade." + else + echo "\nContinuing with brew upgrade." + brew upgrade; + fi + fi + + # Potentially upgrade casks + if [ ${#outdated_c} = 1 ]; then + echo "No casks to update." + else + echo "\nCasks to update:\n" + brew cask outdated --greedy; + notify "Cask: Finished reading updates" "Click to view outdated casks." + echo -n "Continue? [Y/n]" + read -sqn CONF + + if [ "$CONF" != "y" ]; then + echo "\nCancelled cask upgrade." + else + echo "\nContinuing with cask upgrade." + brew cask upgrade --greedy; + fi + fi + + # Final steps & cleanup + brew cleanup -s; + brew cask cleanup; + brew prune; + brew doctor; + brew missing; + notify "Brewed." "All packages have been upgraded."; +else + echo "Cannot upgrade Homebrew packages. Please do so manually." +fi + +### Mac App Store (MAS) ### +if command -v mas &> /dev/null; then + echo "MAS outdated:" + mas outdated + + echo -n "Continue? [Y/n]" + read -sqn CONF + + if [ "$CONF" != "y" ]; then + echo "\nCancelled mas upgrade." + else + echo "\nContinuing with brew upgrade." + mas upgrade; + fi + notify "MAS Updated." "All apps at newest version." +else + echo "Cannot update Mac App Store apps. Please do so manually." +fi + +### NPM ### +if command -v npm &> /dev/null; then + npm update -g + notify "NPM Update Finished" "See Terminal for info." +else + echo "Cannot update NPM packages. Please do so manually." +fi + +### PIP3 ### +if command -v pip3 list &> /dev/null; then + pip3 list --outdated | cut -d ' ' -f1 | xargs -n1 pip3 install -U + notify "Pip3 Update Finished" "See Terminal for info." +else + echo "Cannot upgrade pip3 packages. Please do so manully." +fi + +### PIP ### +if command -v pip list &> /dev/null; then + pip freeze — local | grep -v ‘^\-e’ | cut -d = -f 1 | xargs pip install -U + notify "Pip Update Finished" "See Terminal for info." +else + echo "Cannot upgrade pip packages. Please do so manully." +fi diff --git a/commonprofile b/commonprofile @@ -52,57 +52,6 @@ notify() { fi } -brewmaster() { - brew update; - brew update > /dev/null; - outdated="$(brew outdated)" - outdated_c="$(brew cask outdated --greedy)" - - # Potentially upgrade programs - if [ ${#outdated} = 1 ]; then - echo "No programs to update." - else - echo "\nTo update:\n" - brew outdated; - notify "Brew: Finished reading updates" "Click to view outdated packages." - echo -n "Continue? [Y/n]" - read -sqn CONF - - if [ "$CONF" != "y" ]; then - echo "\nUser cancelled." - return 1 - fi - echo "\nContinuing with brew upgrade." - brew upgrade; - fi - - # Potentially upgrade casks - if [ ${#outdated_c} = 1 ]; then - echo "No casks to update." - else - echo "\nCasks to update:\n" - brew cask outdated --greedy; - notify "Cask: Finished reading updates" "Click to view outdated casks." - echo -n "Continue? [Y/n]" - read -sqn CONF - - if [ "$CONF" != "y" ]; then - echo "\nUser cancelled." - return 1 - fi - echo "\nContinuing with cask upgrade." - brew cask upgrade --greedy; - fi - - # Final steps & cleanup - brew cleanup -s; - brew cask cleanup; - brew prune; - brew doctor; - brew missing; - notify "Brewed." "All packages have been upgraded."; -} - gemmaster() { gem update; gem update rails; @@ -237,3 +186,24 @@ export CASK_REPO=`brew --repository`/Library/Taps/caskroom/homebrew-cask ### THEFUCK ### eval $(thefuck --alias) ############## + +### VIRTUALENV ### + +# Set python 3 location +export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 + +# activate virtualenvwrapper +source /usr/local/bin/virtualenvwrapper.sh + +# pip should only run if there is a virtualenv currently activated +export PIP_REQUIRE_VIRTUALENV=true + +# create commands to override pip restriction. +# use `gpip` or `gpip3` to force installation of +# a package in the global python environment +gpip(){ + PIP_REQUIRE_VIRTUALENV="" pip "$@" +} +gpip3(){ + PIP_REQUIRE_VIRTUALENV="" pip3 "$@" +}