Last active
December 2, 2022 06:36
-
-
Save mitchbne/eae9c288b9c1daa35a7e9ba41599a9d2 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -e; | |
# Variables | |
TERMINAL_RC_FILE="$HOME/.zshrc" | |
DEFAULT_NODE_VERSION="14" | |
DEFAULT_RUBY_VERSION="2.7.3" | |
# Install Homebrew | |
if ! brew -v >/dev/null 2>&1; then | |
echo "Installing Homebrew" | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $TERMINAL_RC_FILE | |
source $TERMINAL_RC_FILE | |
fi | |
# Install ZSH | |
if ! command -v zsh >/dev/null 2>&1; then | |
echo "Installing ZSH" | |
brew install zsh | |
chsh -s /usr/local/bin/zsh | |
fi | |
# Install xcode tools | |
if ! command -v xcode-select >/dev/null 2>&1; then | |
echo "Installing xcode tools" | |
xcode-select --install | |
fi | |
# Install Git | |
if ! command -v git >/dev/null 2>&1; then | |
echo "Installing Git" | |
brew install git | |
fi | |
# Configure Git | |
if [ ! -f $HOME/.gitconfig ]; then | |
echo "Configuring Git...." | |
read -p "Enter your GitHub username: " github_username | |
read -p "Enter your GitHub email: " github_email | |
git config --global color.ui true | |
git config --global user.name "$github_username" | |
git config --global user.email "$github_email" | |
fi | |
# Setup Rbenv | |
if ! command -v rbenv >/dev/null 2>&1; then | |
echo "Setting up Rbenv..." | |
brew install rbenv ruby-build | |
echo "" >> $TERMINAL_RC_FILE | |
echo 'eval "$(rbenv init - zsh)"' >> $TERMINAL_RC_FILE | |
echo "" >> $TERMINAL_RC_FILE | |
source $TERMINAL_RC_FILE | |
rbenv install $DEFAULT_RUBY_VERSION | |
rbenv global $DEFAULT_RUBY_VERSION | |
fi | |
# Setup Node | |
if ! command -v node >/dev/null 2>&1; then | |
echo "Setting up NVM..." | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash | |
echo 'export NVM_DIR=$HOME/.nvm' >> $TERMINAL_RC_FILE | |
echo 'source $HOME/.nvm/nvm.sh' >> $TERMINAL_RC_FILE | |
source $TERMINAL_RC_FILE | |
nvm install --default $DEFAULT_NODE_VERSION; | |
nvm use $DEFAULT_NODE_VERSION; | |
fi | |
# Install Yarn | |
if ! command -v yarn >/dev/null 2>&1; then | |
echo "Installing Yarn..." | |
npm install --global yarn | |
fi | |
# Install SSM Plugin (for SSMing into AWS instances) | |
if ! brew list session-manager-plugin >/dev/null 2>&1; then | |
echo "Installing AWS Session Manager..." | |
brew install --cask --no-quarantine session-manager-plugin | |
fi | |
# Setup SSH | |
if [ ! -f $HOME/.ssh/id_ed25519 ]; then | |
echo "Setting up SSH..." | |
# Create SSH key | |
read -p "Enter your Tanda email address: " tanda_email_address | |
ssh-keygen -t ed25519 -f $HOME/.ssh/id_ed25519 -N "" -C "$tanda_email_address" | |
# Add your SSH key to the SSH agent | |
eval "$(ssh-agent -s)" >/dev/null 2>&1 | |
if [ ! -f $HOME/.ssh/config ]; then | |
touch $HOME/.ssh/config | |
echo "Host *" >> $HOME/.ssh/config | |
echo " AddKeysToAgent yes" >> $HOME/.ssh/config | |
echo " UseKeychain yes" >> $HOME/.ssh/config | |
# Note: We intentionally use the actual value of "$HOME" here because ssh doesn't eval the config script | |
echo " IdentityFile $HOME/.ssh/id_ed25519" >> $HOME/.ssh/config | |
echo " ServerAliveInterval 15" >> $HOME/.ssh/config | |
fi | |
ssh-add --apple-use-keychain $HOME/.ssh/id_ed25519 | |
# Add SSH Key to GitHub | |
pbcopy < $HOME/.ssh/id_ed25519.pub | |
echo "Your SSH key has been added to your clipboard." | |
echo "You can add it to your GitHub account by going to https://github.com/settings/ssh/new" | |
fi | |
echo "All done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment