From 1bad657c315f5f212572b73e8d43493c5d24103c Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 19 Oct 2016 21:39:48 +0200 Subject: [PATCH] A harder, better, faster, stronger bin/update.sh --- bin/update.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 bin/update.sh diff --git a/bin/update.sh b/bin/update.sh new file mode 100755 index 00000000..994be953 --- /dev/null +++ b/bin/update.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o errexit,nounset + +update() { + [[ -d $1 ]] || return + + pushd "$1" + local L=$(git rev-parse @) + local R=$(git rev-parse @{u}) + if [[ $L != $R ]] + then + echo "Updating $(basename $(pwd))" + shift + ${@:-git pull} + fi + popd +} + +# Update OS +case "$OSTYPE" in + darwin*) + brew update && brew upgrade && brew cleanup + ;; + linux*) + if command -v pacman >/dev/null; then + sudo pacman -Syu --noconfirm + elif command -v apt-get >/dev/null; then + sudo apt-get update && sudo apt-get upgrade -y + fi +esac + +# Update editors +update ~/.emacs.d "make update" +update ~/.vim "make update" + +# Others +update ~/.zgen +update ~/.cask +update ~/.{rb,py}env +