#!/bin/sh # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU Affero General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more # details. main() { DOTFILES_REMOTE="origin" DOTFILES_BRANCH="master" # Handle opts while getopts ":h" opt do case "$opt" in b) DOTFILES_BRANCH="$OPTARG" ;; h) usage && exit 0 ;; u) DOTFILES_REMOTE="$OPTARG" ;; *) printf "Invalid option passed: %s\n" "$OPTARG" >&2 ;; esac done shift $(( OPTIND - 1 )) # Stash any pending changes git -C "$HOME" stash # Update the main repository git -C "$HOME" fetch "$DOTFILES_REMOTE" "$DOTFILES_BRANCH" git -C "$HOME" reset --hard "$DOTFILES_REMOTE/$DOTFILES_BRANCH" # Pull updates for all submodules git -C "$HOME" submodule update --init --recursive --remote # Apply the stash git -C "$HOME" stash apply } usage() { cat <] [-u ] Utility application for dotfile maintenance. Options: -b The name of the branch to use, defaults to "master" -h Show this help text and exit. -u The name of the remote to use, defaults to "origin" EOF } main "$@"