diff --git a/bin/dotfiles-update-modules b/bin/dotfiles-update-modules index 4dde6c7..7d7951c 100755 --- a/bin/dotfiles-update-modules +++ b/bin/dotfiles-update-modules @@ -1,12 +1,30 @@ #!/bin/zsh -cd -cd .vim/bundle -for a in `ls`; do - cd $a - git checkout master && git pull --rebase - cd .. -done -cd ~/.oh-my-zsh -git checkout master && git pull --rebase -cd +function usage() { + echo "Usage: `basename $0` [-h] [-u]" 1>&2 + echo "stash, update and add modules, commit and pop stash" 1>&2 + echo "-u only update modules" 1>&2 + exit 1 +} + +if [[ "$1" == "-h" ]]; then + usage +fi + +if [[ "$1" != "-u" ]]; then + dotfiles stash +fi +foreach module (`ls -d ~/.vim/bundle/* ~/.oh-my-zsh`) + echo "Updating $module" + cd $module + git checkout master + git pull + if [[ "$1" != "-u" ]]; then + dotfiles add $module + fi +end +if [[ "$1" != "-u" ]]; then + cd + dotfiles commit -s -m "Update modules" + dotfiles stash pop +fi