Last active
November 10, 2023 22:05
-
-
Save ztrayner/1a6f7fb77e0795fcbf7dd87cac243b60 to your computer and use it in GitHub Desktop.
Mac setup 2023 JavaScript Engineer
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 | |
# Save this script as setup_mac.sh, make it executable with chmod +x ./setup_mac.sh, and run it with ./setup_mac.sh | |
POWERLEVEL10K_PATH="/opt/homebrew/share/powerlevel10k/powerlevel10k.zsh-theme" | |
# Set up Git | |
git_name=$(git config --global --get user.name) | |
git_email=$(git config --global --get user.email) | |
git_push_default=$(git config --global --get push.default) | |
git_push_autosetupremote=$(git config --global --get push.autoSetupRemote) | |
gitconfig_path="$HOME/.gitconfig" | |
if [ -z "$git_name" ]; then | |
read -p "Enter your full name for Git: " git_name | |
echo "[user]" >> "$gitconfig_path" | |
echo " name = \"$git_name\"" >> "$gitconfig_path" | |
fi | |
if [ -z "$git_email" ]; then | |
read -p "Enter your email for Git: " git_email | |
echo " email = \"$git_email\"" >> "$gitconfig_path" | |
fi | |
if [ "$git_push_default" != "current" ]; then | |
git config --global push.default current | |
fi | |
if [ "$git_push_autosetupremote" != "true" ]; then | |
git config --global push.autoSetupRemote true | |
fi | |
# Set fetch.prune to true | |
if ! git config --global --get fetch.prune; then | |
git config --global fetch.prune true | |
fi | |
# Set pull.rebase to true | |
if ! git config --global --get pull.rebase; then | |
git config --global pull.rebase true | |
fi | |
# Install Homebrew if not already installed | |
if ! command -v brew &> /dev/null; then | |
/bin/bash -c "$(curl -fsSL | |
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
fi | |
# Update Homebrew and install core tools | |
brew update | |
brew install git wget zsh | |
# Set up git | |
git config --global user.name "$FULL_NAME" | |
git config --global user.email "$EMAIL" | |
git config --global core.editor "nano" | |
# Install Google Chrome if not already installed | |
if ! ls /Applications | grep -q 'Google Chrome.app'; then | |
brew install --cask google-chrome | |
echo "Google Chrome has been installed. Please log in to Chrome and | |
Github and then press Enter to continue." | |
# Open the GitHub login | |
open -a "Google Chrome" "https://github.com/login" | |
read -s -n 1 | |
fi | |
# Generate SSH key and add it to GitHub if it doesn't exist | |
if [ ! -f ~/.ssh/id_ed25519 ]; then | |
ssh-keygen -t ed25519 -C "$EMAIL" | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/id_ed25519 | |
echo "Please add the following public key to your GitHub account:" | |
cat ~/.ssh/id_ed25519.pub | |
# Copy the public key to the clipboard | |
pbcopy < ~/.ssh/id_ed25519.pub | |
echo "The public key has been copied to your clipboard." | |
# Open the GitHub SSH keys page in Chrome | |
open -a "Google Chrome" "https://github.com/settings/ssh/new" | |
echo "Press Enter after adding the key to your GitHub account to | |
continue" | |
read -s -n 1 | |
fi | |
# Install desired software | |
brew install --cask firefox visual-studio-code slack docker \ | |
spotify zoom rectangle figma kap pgadmin4 authy | |
brew install lsd imagemagick gifsicle ffmpeg nvm | |
# Install Xcode | |
xcode-select --install | |
# Accept the Xcode license agreement | |
sudo xcodebuild -license accept | |
# NVM setup | |
mkdir -p ~/.nvm | |
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc | |
echo '[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && . "/opt/homebrew/opt/nvm/nvm.sh"' >> ~/.zshrc | |
source ~/.zshrc | |
nvm install --lts | |
nvm use --lts | |
npm install -g pnpm | |
# Install Powerlevel10k theme for Zsh if not already installed | |
if ! grep -qxF "source $POWERLEVEL10K_PATH" ~/.zshrc; then | |
brew install powerlevel10k | |
echo "source $POWERLEVEL10K_PATH" >> ~/.zshrc | |
fi | |
# Configure Dock settings | |
defaults write com.apple.dock autohide -bool true | |
defaults write com.apple.dock autohide-delay -float 0 | |
defaults write com.apple.dock autohide-time-modifier -float 0 | |
killall Dock | |
# Configure Trackpad settings | |
defaults write -g com.apple.trackpad.scaling -float 3.0 | |
defaults write -g InitialKeyRepeat -int 15 | |
defaults write -g KeyRepeat -int 2 | |
# Enable Dark Mode | |
defaults write -g NSRequiresAquaSystemAppearance -bool false | |
# Enable Finder path bar | |
defaults write com.apple.finder ShowPathbar -bool true | |
# Enable Finder status bar | |
defaults write com.apple.finder ShowStatusBar -bool true | |
# Show hidden files in Finder | |
defaults write com.apple.finder AppleShowAllFiles -bool true | |
# Show file extensions in Finder | |
defaults write -g AppleShowAllExtensions -bool true | |
# Restart Finder to apply changes | |
killall Finder | |
# Install image optimization tools | |
brew install svgo pngquant | |
# Set default browser to Chrome | |
open -a "Google Chrome" --args --make-default-browser | |
# Apply macOS settings | |
killall Dock | |
killall Finder | |
echo "Setup complete. Please restart your computer for all settings to take effect." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment