#!/bin/bash # Install remotely from single shell command # Usage : sh -c "$(curl -fsSL https://tinyurl.com/miguelenes)" if [ "$(uname)" == "Darwin" ]; then echo "Installing Xcode Command Line Tools" xcode-select --install echo "Installing Command Line Tools for Xcode" # Only run if the tools are not installed yet # To check that try to print the SDK path xcode-select -p &> /dev/null if [ $? -ne 0 ]; then echo "Command Line Tools for Xcode not found. Installing from softwareupdate…" touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress; PROD=$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //') softwareupdate -i "$PROD" --verbose; else echo "Command Line Tools for Xcode have been installed." fi if [ ! "$(command -v brew)" ]; then sh -c HOMEBREW_NO_ENV_HINTS=1 NONINTERACTIVE=1 "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" else HOMEBREW_NO_ENV_HINTS=1 brew update --auto-update --force --quiet brew install curl git gnupg chezmoi --overwrite --quiet fi elif [ "$(expr substr "$(uname -s)" 1 5)" == "Linux" ]; then if [ ! "$(command -v apt)" ]; then sudo apt update sudo apt full-upgrade -y sudo apt install fi fi set -e # -e: exit on error if [ ! "$(command -v chezmoi)" ]; then bin_dir="$HOME/.local/bin" chezmoi="$bin_dir/chezmoi" if [ "$(command -v chezmoi)" ]; then if [ "$(command -v curl)" ]; then sh -c "$(curl -fsSL https://git.io/chezmoi)" -- -b "$bin_dir" elif [ "$(command -v wget)" ]; then sh -c "$(wget -qO- https://git.io/chezmoi)" -- -b "$bin_dir" else echo "To install chezmoi, you must have curl or wget installed." >&2 exit 1 fi fi else chezmoi=chezmoi fi sudo chsh -s "$(which zsh)" "$USER" sudo rm -R ~/.local/share/chezmoi || true "$chezmoi" state reset --force --keep-going || true # exec: replace current process with chezmoi init exec "$chezmoi" init --apply miguelenes --keep-going --force