From 8fff11535e9d9cafba915f30f0624559ff2e837e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 13 Dec 2015 06:46:47 -0500 Subject: [PATCH] Reorganize + give scripts appropriate extension --- scripts/install.sh => install.sh | 2 +- scripts/{org-clean.sh => org-clean.zsh} | 6 +-- scripts/update.sh | 27 ------------ scripts/update.zsh | 55 +++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 31 deletions(-) rename scripts/install.sh => install.sh (83%) rename scripts/{org-clean.sh => org-clean.zsh} (85%) delete mode 100755 scripts/update.sh create mode 100755 scripts/update.zsh diff --git a/scripts/install.sh b/install.sh similarity index 83% rename from scripts/install.sh rename to install.sh index 03af75f3..8188f4c2 100755 --- a/scripts/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ ~/.vim/install.sh shopt -s extglob -for rcfile in "$HOME"/.dotfiles/!(bin|scripts|README.md|Gemfile*); do +for rcfile in "$HOME"/.dotfiles/!(bin|scripts|README.md|install.sh|Gemfile*); do filep="$HOME/."$(basename "$rcfile") [ "$1" == "--force" ] && rm -f "$filep" diff --git a/scripts/org-clean.sh b/scripts/org-clean.zsh similarity index 85% rename from scripts/org-clean.sh rename to scripts/org-clean.zsh index da15b943..71be43cc 100755 --- a/scripts/org-clean.sh +++ b/scripts/org-clean.zsh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env zsh # A cleanup script for attachments in my org-mode notes. @@ -20,7 +20,7 @@ is_orphaned_file() { ag -Q "$1" >/dev/null } -if [ "$1" == "-n" ]; then +if [[ "$1" == "-n" ]]; then DRY_RUN=1 echo "Running dry run!" fi @@ -29,7 +29,7 @@ for folder in $(attachment_dirs); do cd "$folder" for file in $(attachments_in_dir "$folder"); do if ! is_orphaned_file "$file"; then - [ -z "$DRY_RUN" ] && rm -f "$file" + [[ -z "$DRY_RUN" ]] && rm -f "$file" echo "Deleted '$file'" fi done diff --git a/scripts/update.sh b/scripts/update.sh deleted file mode 100755 index 66cc9bf7..00000000 --- a/scripts/update.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/zsh - -set -e - -brew update && brew upgrade --all -cd "$HOME/.emacs.d" && make update - -local i -if [ -d ~/.rbenv ]; then - cd "$HOME/.rbenv" && git pull - for i in "$HOME"/.rbenv/plugins/*; do - cd "$i" && git pull - done -fi - -if [ -d ~/.pyenv ]; then - cd "$HOME/.pyenv" && git pull - for i in "$HOME"/.pyenv/plugins/*; do - cd "$i" && git pull - done -fi - -if [ -d ~/.zsh/zgen ]; then - source ~/.zsh/zgen/zgen.zsh - zgen selfupdate - zgen update -fi diff --git a/scripts/update.zsh b/scripts/update.zsh new file mode 100755 index 00000000..b7e3099c --- /dev/null +++ b/scripts/update.zsh @@ -0,0 +1,55 @@ +#!/usr/bin/env zsh + +set -e + +indent() { sed 's/^/ /'; } +up-to-date() { + LOCAL=$(git rev-parse @) + REMOTE=$(git rev-parse @{u}) + [[ "$LOCAL" == "$REMOTE" ]] +} + +(( $+commands[brew] )) && { + echo "Updating homebrew" + { brew update && brew upgrade --all; } | indent +} + +[[ -f "$HOME/.emacs.d/Makefile" ]] && { + echo -n "Updating emacs" + cd "$HOME/.emacs.d" && make update | indent +} + +local env=(rb py) +for i in $env +do + [[ -d "$HOME/.${i}env" ]] && { + echo "Updating ${i}env" + { + if ! up-to-date; then + echo "UPDATING" + git pull > /dev/null + fi + + { + for plugin in "$HOME"/.${i}env/plugins/* + do + cd "$plugin" + if ! up-to-date; then + echo "+ UPDATING `basename ${plugin}`" + git pull > /dev/null + fi + done + } 2&>1 | indent + } 2&>1 | indent + } +done + +[[ -d ~/.zsh/zgen ]] && { + echo "Updating zgen" + { + source "$HOME/.zsh/zgen/zgen.zsh" + zgen selfupdate + zgen update + } 2&>1 | indent +} +