Last active
May 31, 2024 19:40
-
-
Save robwilkerson/b785752880575b7a6ca5abe9df71276e to your computer and use it in GitHub Desktop.
MacOS Bootstrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Does the bare minimum that's required before we can begin to kick things off. | |
# We need homebrew to install git, git to configure the basics, and Proton Drive | |
# in order to pull down the rest of the MacOS configuration scripts. | |
# | |
# curl -sL https://gist.githubusercontent.com/robwilkerson/b785752880575b7a6ca5abe9df71276e/raw | bash | |
# | |
set -euxo pipefail | |
bash -c 'echo "Bootstrapping a (presumably) new MacOS device..."' | |
# Optionally, set a custom name for the computer | |
read -rp "Set the computer name ($(scutil --get HostName))" computer_name | |
if [ -n "${computer_name}" ]; then | |
scutil --set HostName "${computer_name}" | |
fi | |
# Install XCode's command line tools | |
if [ -z "$(xcode-select -p)" ]; then | |
xcode-select --install | |
fi | |
# Install Homebrew | |
echo | bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
# Install a few core essentials immediately | |
# git: version control | |
# proton-drive: cloud file storage; all additional init scripts are stored there | |
brew update | |
brew install git \ | |
proton-drive | |
# Create a SSH key to use with Github | |
if [[ ! -f "${HOME}/.ssh/github-$(scutil --get HostName)" ]]; then | |
ssh-keygen -t ed25519 -N "" -C "Github SSH Key" -f "${HOME}/.ssh/github-$(scutil --get HostName)" | |
fi | |
# Add a SSH config entry for Github using the generated key | |
# This will allow us to clone the dotfiles repo, but will have to be run | |
# again to be sure that this computer's config gets this computer's key. | |
cat << EOF >> ~/.ssh/config | |
Host github.com | |
AddKeysToAgent yes | |
UseKeychain yes | |
IdentityFile ~/.ssh/github-$(scutil --get HostName) | |
EOF | |
# | |
# Sign in to a few key applications | |
# | |
# Mac App Store | |
read -rsn1 -p "Please sign in to the App Store; press any key to launch"; echo | |
open '/System/Applications/App Store.app' | |
read -rsn1 -p "Once signed in to the App Store, press any key to continue."; echo | |
# Proton Drive (to pull init scripts) | |
read -rsn1 -p "Please sign in to Proton Drive; press any key to launch"; echo | |
open "/Applications/Proton Drive.app" | |
read -rsn1 -p "Once signed in to Proton Drive, press any key to continue."; echo | |
# Copy the public key to the clipboard and open the Github settings page | |
echo "Copying the public key to the clipboard and opening Github..." | |
cat "${HOME}/.ssh/github-$(scutil --get HostName).pub" | pbcopy | |
open https://github.com/settings/keys | |
read -rsn1 -p "Press any key to continue after adding the public key to Github"; echo | |
cat << EOF | |
The basics are in place! Give the macos-setup | |
scripts time to download and kick them off! | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment