#!/usr/bin/env sh usage() { 1>&2 printf -- 'Usage: %s [-hrf]\n' "$0" 1>&2 printf -- '\t-h: Show help menu\n' 1>&2 printf -- '\t-r: Refresh repository\n' 1>&2 printf -- '\t-x: Install VSCodium extensions\n' 1>&2 printf -- '\t-f: Force install\n' } unset REFRESH CODIUM_EXTENSIONS FORCE cd "$(dirname "$0")" || exit 1 while getopts "hrxf" opt; do case "$opt" in h) usage exit 0 ;; r) REFRESH=1 ;; x) CODIUM_EXTENSIONS=1 ;; f) FORCE=1 ;; *) usage exit 1 ;; esac done install_codium_extensions() { if command -v codium >/dev/null; then printf '%s\n' 'Installing VSCodium extensions...' grep -v '^ *#' <.config/VSCodium/extensions.txt | while IFS= read -r line; do printf '%s\n' "$line" codium --install-extension "$line" >/dev/null done else printf '%s\n' 'VSCodium is not installed' fi } install_dots() { rsync --exclude-from=.bootstrapignore -avgh --no-perms . "$HOME" || { printf '%s\n' 'rsync failed; aborted' >&2 exit 1 } } if [ "$REFRESH" ]; then git pull --recurse-submodules fi if [ "$CODIUM_EXTENSIONS" ]; then install_codium_extensions exit fi if [ "$FORCE" ]; then install_dots else printf '%s' 'This may overwrite the existing configuration. Are you sure? [y/N] ' read -r REPLY case "$REPLY" in [Yy]) install_dots ;; *) exit 1 ;; esac fi unset REFRESH FORCE CODIUM_EXTENSIONS install_codium_extensions install_dots