Setting Up Your macOS Development Environment and Automating Backups.
My Repo : My-Mac-Settings
I recently got a new M3 Max 14" for myself and wanted to port over all my setup from earlier 14" M1 pro. Hence I came up with below scripts to make things easy for me.
Please leave your suggestions & thoughts.
In this comprehensive guide, I'll walk you through the process of setting up a robust development environment on your macOS system. I'll cover everything from installing essential tools and applications to automating the backup of critical configuration files.
My Brewfile contains all the apps installed via Homebrew, Macapp Store and also all of my VSCode extensions.
Then we will use the script auto_update_Brewfile.sh
to update & upgrade brew formulae and apps installed using Homebrew. It also backups .zshrc
file if it has been changed in past week.
Below are the paid apps I am using.
You can go through the entire list of apps in my Brewfile and remove or add apps as per your need.
AlDente Pro
AlDente Pro is a premium application designed to manage your MacBook's battery and charging effectively. It optimizes your battery's lifespan and keeps you informed about its health. Learn more about it here.
iStat Menus
iStat Menus offers real-time monitoring of your Mac's performance, including CPU usage, memory utilization, and network statistics. It's a powerful tool for keeping an eye on your system's health. Explore it further here.
Raycast
Raycast is a productivity powerhouse that replaces Spotlight and provides quick access to a wide range of functions. It enhances your workflow and simplifies everyday tasks. Discover more about it here.
Warp Terminal.
Warp is free for now and my goto terminal app which replaced iTerm for me. Its beautiful and very easy to use, I have paired it up with a free app called Fig.io
The Heart of the Setup: setup_dev_env.sh
Script
The setup_dev_env.sh
script is a powerful automation tool for macOS. It's designed to perform the following tasks:
- Check for and install Homebrew.
- Download a Brewfile from a specified URL.
- Use Homebrew to install all the software listed in the Brewfile.
Initial Steps: Downloading and Running the Script
Downloading the Script: You can either clone the script from a my repository or copy-paste it directly from the here.
Hosting the Brewfile: Your Brewfile, which lists all the desired software and packages, should be hosted online and accessible via a direct URL. This URL is used by the script to download the Brewfile.
Modifying and Executing the Script: After downloading, modify the script to include the URL of your Brewfile. Then, run the script in the terminal after giving it execute permissions using chmod +x setup_dev_env.sh
.
Automating Brewfile Backups with Crontab
An essential part of managing a development environment is keeping your software list up to date. This is where the auto_update_Brewfile.sh
script comes in, coupled with cron jobs for automation.
Setting Up Cron Jobs: Use crontab -e
to edit your cron jobs. Add a line to schedule the backup script to run at specific times, like every Friday and Sunday at 7 PM.
You can check if there are any present cron tasks or your changes have been made correctly or not by using crontab -l
command.
It will show output as below.
Script Execution and Permissions: Make sure the backup script is executable by using chmod +x auto_update_Brewfile.sh
.
Backup and Update: The script updates brew formulae, upgrades installed apps, backs up the old Brewfile, generates a new one, back ups .zshrc file if it has been changed in past week and pushes the updates to a specified GitHub repository.
Troubleshooting and Tips
Regularly check your cron jobs and script logs to ensure they're running as expected.
Test the scripts manually before relying on the automated schedule.
Conclusion
With the setup and automation described in this guide, you can easily maintain a robust development environment on your macOS system. Plus, you'll have peace of mind knowing that your essential configuration files are automatically backed up on GitHub.
Start by forking My-Mac-Settings and following the steps outlined here or in the readme. Enjoy your optimized macOS experience!
Top comments (4)
Great work :)
Thank You Raj
Nice.. how long did it took to set these up and how much time has does it save for you once your automation is ready?
It took me around 2-3 hours to set these script up and they evolved as well after the intial
Idea. The time saved it few hours for the intial setup and then the updating of these apps is may be 10 mins or so.
My main motto was to automate the repetitive task and these should not require active intervention from me to be completed.