#!/bin/bash # -C : Prevent overwriting existing files when redirecting output. # - Helps to avoid accidentally overwriting files when using # redirection operators like > or >> in the script. # -e : Exit the script if any command returns a non-zero status. # - Ensures the script stops on the first error encountered. # -u : Exit the script if an undefined variable is used. # - Prevents running commands with unintended variables. # -o pipefail : Change pipeline exit status to the last non-zero exit code # in the pipeline, or zero if all commands succeed. # - Ensures proper error handling in pipelines. # -x : (Optional) Enable command tracing for easier debugging. # - Uncomment this option to debug the script. set -Ceuo pipefail # ---------------------------------------------------------------- # utils # ---------------------------------------------------------------- yellow='\033[1;33m' reset='\033[0m' request_admin_privileges() { if [ "${CI:-false}" = "true" ]; then return fi echo -e "- πŸ‘¨πŸ»β€πŸš€ Please enter your password to grant sudo access for this operation" sudo -v # Temporarily increase sudo's timeout until the process has finished ( while true; do sudo -n true sleep 60 kill -0 "$$" || exit done ) 2> /dev/null & } # This function installs the Xcode Command Line Tools if they are not already installed. # # @See # https://gist.github.com/mokagio/b974620ee8dcf5c0671f # http://apple.stackexchange.com/questions/107307/how-can-i-install-the-command-line-tools-completely-from-the-command-line install_xcode_cli_tools() { echo -e "πŸ‘¨πŸ»β€πŸš€ Install Xcode CLI tools" echo "- πŸ‘¨πŸ»β€πŸš€ Checking Xcode CLI tools..." # Check if Xcode CLI tools are already installed by trying to print the SDK path. if xcode-select -p &> /dev/null; then echo "- πŸ‘¨πŸ»β€πŸš€ Xcode CLI tools are already installed" else echo "- πŸ‘¨πŸ»β€πŸš€ Xcode CLI tools not found. Installing them..." TEMP_FILE="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress" touch "${TEMP_FILE}" CLI_TOOLS=$(softwareupdate -l \ | grep "\*.*Command Line" \ | tail -n 1 | sed 's/^[^C]* //') echo "- πŸ‘¨πŸ»β€πŸš€ Installing: ${CLI_TOOLS}" softwareupdate -i "${CLI_TOOLS}" --verbose rm "${TEMP_FILE}" fi echo -e "πŸ‘¨πŸ»β€πŸš€ Xcode CLI tools are ready to go πŸŽ‰" } open_config_apps() { if [ "$CI" = "true" ]; then echo "Running in CI environment - skipping app opening" return fi echo "πŸ‘¨πŸ»β€πŸš€ Open the apps that needs to be configured" open -b com.apple.systempreferences open "/Applications/Google Drive.app" open "/Applications/Google Chrome.app" open "/Applications/Raycast.app" open "/Applications/1Password.app" open "/Applications/Karabiner-Elements.app" open /users open https://github.com/nozomiishii/dotfiles echo "πŸ‘¨πŸ»β€πŸš€ Please refer to github to set up the launched application" } # ---------------------------------------------------------------- # Install # ---------------------------------------------------------------- echo -e "${yellow}" cat << EOF πŸ‘¨πŸ»β€πŸš€ Nozomiishii Doting Dotfiles Get ready for your ultimate Mac setup! β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β• β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘ β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘β–‘β•šβ•β•β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β•šβ•β•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β–‘β–‘β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β–‘ EOF echo -e "${reset}" request_admin_privileges install_xcode_cli_tools sh -c "$(curl -fsLS get.chezmoi.io)" -- -b "$HOME/.local/bin" init --apply nozomiishii --verbose open_config_apps echo -e "${yellow}" cat << EOF β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–‘β–‘β•šβ•β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β•šβ•β•β•β–ˆβ–ˆβ•—β•šβ•β• β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–‘β•šβ–ˆβ–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•— β–‘β•šβ•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β•šβ•β•β–‘β–‘β•šβ•β•β•β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β–‘β–‘β•šβ•β•β•šβ•β•β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β• πŸŽ‰ All dotfiles installation is now complete πŸŽ‰ πŸ‘¨πŸ»β€πŸš€ Restart your mac to reflect the settings. Happy Coding🫰🏻 run: sudo reboot EOF echo -e "${reset}"