Setup my Mac
Setting up a new Mac is always an exciting experience, especially for developers. It’s like a fresh start, and with the right setup, you can transform your new device into a powerful workstation for coding, testing, and building cool projects. In this guide, I’ll walk you through the exact tools and configuration I use when I set up a new Mac, focusing on Python development and general productivity. Let’s get started!
Step 1: Install Homebrew, Your Package Manager
The first step in setting up a new Mac is to install Homebrew, a package manager that makes it easy to install and manage software and tools on macOS. Run the following command in your Terminal to download and install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once Homebrew is installed, update its formulae to ensure the latest versions of the packages are available:
brew update
Step 2: Install pyenv and Manage Python Versions
For Python development, it’s essential to have multiple versions installed (e.g., 3.11, 3.12, 3.13, etc.), especially for testing compatibility across projects. Using pyenv, we can easily manage different Python versions on the same machine.
Install pyenv
Run the following command to install pyenv via Homebrew:
brew install pyenv
Configure pyenv
Update your shell configuration (~/.zshrc) to initialize pyenv and its required environment variables. Add the following lines:
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init --path)"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
Then reload your shell:
source ~/.zshrc
Install Required Build Tools
Before installing Python versions, ensure you have the required dependencies:
brew install openssl readline sqlite3 xz zlib
Install Python Versions
Now, install the desired Python versions with pyenv. In this setup, we’ll install Python 3.11.6, 3.12.2, and the latest 3.13 version:
pyenv install 3.11.6
pyenv install 3.12.2
pyenv install 3.13.4
You can check all Python versions installed by running:
pyenv versions
Optionally, set a global Python version (e.g., the latest one):
pyenv global 3.13.4
If you need to switch to a specific Python version for a project, you can use:
pyenv local 3.12.2
Congratulations! You’re now managing multiple Python versions on your machine.
Step 3: Global .gitignore and .env Setup
Create a Global .gitignore File
To streamline your Git workflow, a global .gitignore file will exclude files you never want in your repositories (like macOS system files, Python bytecode, or editor-specific files). Create and configure your global .gitignore file:
- Create the file:
touch ~/.gitignore_global - Add common ignores (like
.DS_Store,__pycache__, etc.). Edit the file with your favorite editor:nano ~/.gitignore_globalExample content:
# macOS system files .DS_Store .AppleDouble .LSOverride # Python files __pycache__/ *.py[cod] .venv/ venv/ # Editor-specific files .vscode/ *.swp - Configure Git to use the global
.gitignore:git config --global core.excludesfile ~/.gitignore_global
Create a Global .env File
If you frequently use environment variables (e.g., for API keys, database URLs), you can create a global .env file. Here’s how:
- Create the
.envfile in your home directory:touch ~/.env - Add your environment variables (use placeholders as examples):
nano ~/.envExample content:
# Global Environment Variables SECRET_KEY=your-secret-key-here DATABASE_URL=mysql://user:password@localhost:3306/mydatabase API_KEY=your-api-key-here - Automatically source the
.envfile when your shell starts. Add this line to your~/.zshrc:echo "source ~/.env" >> ~/.zshrc - Reload your shell:
source ~/.zshrc
Step 4: Install Essential Apps
Here are the essential apps and tools I install to enhance productivity and development:
Install them via Homebrew:
brew install --cask spotify docker caffeine google-chrome zoom warp windsurf slack
Here’s a quick breakdown of the installed tools:
- Spotify: Keeps you motivated with music.
- Docker: Run containers for testing and distributing applications.
- Google Chrome: A developer-friendly browser with great extensions.
- Zoom: Essential for meetings and remote collaboration.
- Warp: A modern, productivity-optimized terminal.
- Postman (optional): Test APIs quickly and efficiently.
Step 5: Setup Workspace and Dependencies
Create a Code Directory
Keep all your coding projects organized in a single directory. Run:
mkdir ~/code
cd ~/code
Clone Personal Projects
If you maintain personal projects (e.g., your blog or GitHub repositories), clone them into this directory:
git clone https://github.com/seduerr91/seduerr91.github.io.git
Step 6: Install Granted for AWS Account Management
If you work with AWS, I recommend installing Granted, which simplifies switching between multiple AWS accounts. Install it following the official Granted Setup Guide.
Conclusion
With this setup, your new Mac is transformed into a highly productive development machine. From managing Python environments to organizing code projects, everything is tailored for maximum efficiency and ease of use. Whether you’re writing Python scripts, deploying containers, or just managing your workflow, you now have the tools to handle it all.