|
#!/bin/bash |
|
set -e # Exit on error |
|
|
|
############ Prerequisites |
|
echo "Please enter your full name for git config: " |
|
read full_name |
|
|
|
echo "Please enter your GitHub noreply email: " |
|
read github_email |
|
|
|
echo "Please enter your email for SSH key comment: " |
|
read email |
|
|
|
############ Homebrew |
|
if ! command -v brew &> /dev/null; then |
|
echo "Installing Homebrew..." |
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
|
fi |
|
|
|
# Initialize Homebrew for current session |
|
eval "$(/opt/homebrew/bin/brew shellenv)" |
|
|
|
# Add to zprofile for login shells |
|
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile |
|
|
|
############ Git |
|
echo "Installing git..." |
|
brew install git |
|
|
|
git config --global user.email "${github_email}" |
|
git config --global user.name "${full_name}" |
|
|
|
# Useful git defaults |
|
git config --global init.defaultBranch main |
|
git config --global pull.rebase true |
|
git config --global fetch.prune true |
|
git config --global diff.colorMoved zebra |
|
|
|
# Global gitignore |
|
git config --global core.excludesfile ~/.gitignore_global |
|
cat << 'EOF' > ~/.gitignore_global |
|
.DS_Store |
|
.envrc |
|
*.duckdb |
|
__pycache__/ |
|
.cache/ |
|
.env |
|
env/ |
|
venv/ |
|
.venv/ |
|
*.pyc |
|
.idea/ |
|
.vscode/ |
|
*.log |
|
EOF |
|
|
|
echo "Global gitignore created at ~/.gitignore_global" |
|
|
|
############ SSH Key |
|
if [ ! -f ~/.ssh/id_ed25519 ]; then |
|
ssh-keygen -t ed25519 -C "${email}" -f ~/.ssh/id_ed25519 |
|
|
|
mkdir -p ~/.ssh |
|
cat << 'EOF' >> ~/.ssh/config |
|
Host github.com |
|
AddKeysToAgent yes |
|
UseKeychain yes |
|
IdentityFile ~/.ssh/id_ed25519 |
|
EOF |
|
|
|
ssh-add --apple-use-keychain ~/.ssh/id_ed25519 |
|
|
|
echo "" |
|
echo "==========================================" |
|
echo "Add this SSH key to GitHub:" |
|
cat ~/.ssh/id_ed25519.pub |
|
echo "==========================================" |
|
echo "Press Enter after adding to GitHub..." |
|
read |
|
fi |
|
|
|
############ Oh My Zsh |
|
if [ ! -d ~/.oh-my-zsh ]; then |
|
echo "Installing Oh My Zsh..." |
|
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended |
|
fi |
|
|
|
# Install zsh plugins |
|
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}" |
|
[ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ] && \ |
|
git clone https://github.com/zsh-users/zsh-autosuggestions "$ZSH_CUSTOM/plugins/zsh-autosuggestions" |
|
[ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ] && \ |
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" |
|
|
|
############ Brew packages |
|
echo "Installing brew formulae..." |
|
xargs brew install < brew.txt |
|
|
|
echo "Installing brew casks..." |
|
xargs brew install --cask < brew_cask.txt |
|
|
|
############ Configure .zshrc |
|
# Backup existing |
|
cp ~/.zshrc ~/.zshrc.backup.$(date +%Y%m%d%H%M%S) |
|
|
|
# Create new .zshrc with proper ordering |
|
cat << 'EOF' > ~/.zshrc |
|
# Homebrew (must be early for PATH) |
|
eval "$(/opt/homebrew/bin/brew shellenv)" |
|
|
|
# Oh My Zsh configuration |
|
export ZSH="$HOME/.oh-my-zsh" |
|
ZSH_THEME="jonathan" |
|
plugins=( |
|
git |
|
gitignore |
|
zsh-autosuggestions |
|
zsh-syntax-highlighting |
|
jump |
|
brew |
|
python |
|
ssh-agent |
|
vscode |
|
fzf |
|
) |
|
|
|
source $ZSH/oh-my-zsh.sh |
|
|
|
# Tool initializations (after oh-my-zsh) |
|
eval "$(atuin init zsh)" |
|
eval "$(zoxide init zsh)" |
|
source <(fzf --zsh) |
|
|
|
# Aliases |
|
alias cat='bat' |
|
alias ls='eza' |
|
alias ll='eza -la' |
|
alias tree='eza --tree' |
|
alias python='python3' |
|
alias pip='pip3' |
|
|
|
############ UV Tools |
|
uv tool install ruff |
|
|
|
|
|
############ Final steps |
|
echo "" |
|
echo "==========================================" |
|
echo "Setup complete!" |
|
echo "" |
|
echo "Next steps:" |
|
echo "1. Restart your terminal or run: source ~/.zshrc" |
|
echo "2. Run 'atuin login' if you want to sync shell history" |
|
echo "3. Run 'gh auth login' to authenticate GitHub CLI" |
|
echo "4. Open Docker Desktop and complete setup" |
|
echo "5. Configure Rectangle, Maccy preferences" |
|
echo "==========================================" |
|
``` |
|
|