Generated AI image by Microsoft Bing Image Creator
Introduction
Happy Belated New Year of 2024!
With the arrival of my shiny new MacBook Pro M2, I will explain In this guide how I setup my machine for a seamless software development experience.
I would love to keep my current Macbook Pro Intel Core i5 2017 edition to continue using it.. But, over the years, the CPU and memory requirements have gone up for more modern full-stack development using Docker, updated Chrome extensions, or upgrade browsers, my limited 8GB RAM and 250GB of SSD storage started to feel small for me to do any decent software development tasks these days. If I knew Apple is incredibly stringent to make memory and storage computing parts non-upgradeable after the purchase is made, I could have turned back the time to request upfront upgrade for these back then, and not to feel the terrible waiting grind for the systems resources to free itself whenever I start up Chrome browser or Docker background process, which ended up to seem like an eternal wait… ⏰⏱
So, forcibly speaking, I have to start moving from my old mac, and say hello to my new Macbook Pro M2!
With all that rant of mine being said, let’s get straight into it!
Table of Contents
- Initial Setup
- Homebrew for Package Management
- Configuring Terminal for Best CLI Developer Experience
- Choosing an IDE
- Containerization with Docker
- Database Setup
- Customizing Your macbook.defaults Environment
- Conclusion
Initial Setup
Start by going through the initial macOS setup process. Make sure your system is updated to the latest version to ensure compatibility with the latest development tools.
Verify the system preferences. ie Apple Icon -> System Settings -> General -> About
Name: <The name of your Macbook Pro M2>
Chip: Apple M2
Memory: 16 GB
Serial Number: <The unique serial number of your machine>
macOS: macOS Sonoma Version 14+
Prior to writing this post, my machine default macOS was macOS Ventura after placing order overseas. To make the software update, Apple Icon -> System Settings -> General -> Software Update -> Click Update Now
and you should be good to go.
Homebrew for Package Management
Homebrew is a powerful package manager for macOS. Install it by running the following command in your terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After this, assuming you use ZSH terminal like I do, you configure the homebrew shell settings to natively run well in ZSH terminal as below:
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile
Do brew update
to make sure the latest brew updates.
At this point, I want to bring all of your favourite software development tools from my old macbook to my new one. The obvious solution I thought would be to download them all, extract them and drag/move to the applications folder, but this is actually very boring and repetitive to do. It’s such a manual process to open/drag/drop everywhere in the screen to this. Thanks to brew, I don’t have to do this anymore.
Instead, we use brew
for that.
Let’s say I want to download Google Chrome browser. What I do is rather to pass in the cask
flag follow by application name I want to download which is google-chrome
With all that said, you run the following
brew install --cask google-chrome
And that’s it!
The incredible thing with this one-liner command is that it downloads from the HomeBrew package site (if it’s available) for the app, installs and moves to the Applications folder for you - without having necessarily to lift any heavy mouse-clicking for the complete the same action. That’s the quick win for your simple automation like that.
With it I can start write up a bash script to add other software downloads as I require like so
#!/bin/.bash
brew install --cask firefox
brew install --cask visual-studio-code
brew install --cask iterm2
# etc, etc
or if you like to DRY up the brew install, you can. You simply use \
keystroke like so.
brew install --cask firefox \
visual-studio-code \
iterm2 \
# etc, etc
It helps to run the brew install actions in parallel. But bear in mind. With this you may run network time-out issue thus some apps you may not able to complete the download times on time. You have to redo the brew install step all over again. So I rather step away from using this for running many things at once. It’s a matter of preference.
For some tooling. in nature, they’re more terminal or CLI based commands, then using cask
wouldn’t make sense. We just simply omit it all together for eg.
brew install git
brew install python3
brew install openjdk
brew install apache-kafka
# etc, etc
And we’re good to go from here.
Configuring Terminal for Best CLI Developer Experience
I’ve used ZSH for years thus I found it to be my second-nature when navigating the developer folder and system resources in my Iterm2 terminal. I also have mentioned about configuring brew for the ZSH profile earlier in this article hence that’s where I’m going with this.
To start, I do the following installation:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Once you installed and configured it, I wanted to enhance my terminal experience further by executing these other 3 tools set at my disposal, which I found them incredibly useful.
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions # --> ZSH Autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting # --> Super Syntax Highlighting
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k # --> PowerLevel10k colour scheme theming over Iterm2
To find out more on their configuration options (and others), you can follow the Medium article for some more setup guidance.
Choosing an IDE
As my primary languages I use these days as of late are ReactJS, TypeScript, Python, Java and NodeJS (though there are others that I can program sufficiently well), Visual Studio Code has been be my primary choice of IDE (though I’m slowly mastering VIM as it’s a CLI-based code editor experience, which is also pretty good)
But overtime, I got more involved in building backend systems development more in my later years of career, I got more accustomed to using IntelliJ and PyCharm Community Editions lately. These are incredibly good as they’re more fully integrated developer experience where as Visual Studio Code is only a code editor on its own. You have to either download the extensions plugin or create the plugins yourself from scratch to match up similar experience as these IDE products.
We can download all of these using brew install cask cli options as stated earlier in the article.
Containerization with Docker
Using Docker for Mac is quite a beast when comes to CPU/memory resources it needs. It always have a high start-up cost of my old Macbook machine every time I load up the mac screen thus have a huge impact on my machine’s overall performance running docker containers locally.
Thankfully, with Macbook M2 Pro machine having a bigger RAM and SDD storage, I have less to worry. Moreover, thanks for its ARM based architecture and the recent Docker community have been opening up their high adoption to have Docker images to run on ARM-based chipsets more than ever before.
With latest releases coming from macOS Sonoma. they will come in time in improving the docker virtualisation memory resources usage and things will get better from here.
Docker for Mac can installed using the brew install cask command as well.
Database Setup
With databases, you have popular choices such as Redis, Mysql, Postgresql, etc. Everything can be downloaded via brew command as well. Again, without the cask
flag.
Be mindful - because their cli-based services which you start and stop these services using brew services start/stop <database-service-name>
, you need a proper database client like DBeaver, DataGrip or similar to interact with them.
They can be downloaded via brew install cask.
Customizing Your macbook.defaults Environment
Last but not the least, I want to overwrite my new Macbook M2 Pro defaults behaviour as part of my goal of enhancing my local development experience on machine further.
I found links like macos-defaults or defaults-write are incredibly helpful with this.
With these, I found that the most obvious ones I want to overwrite is the Dock as I want to recreate same feeling on my old Macbook settings. The settings are to minimize docker by default but with on mouse hover event when to autohide, along with genie mini effect when opening/minimising desktop screens.
They are setup as below:
defaults write com.apple.dock "tilesize" -int "24" && killall Dock
defaults write com.apple.dock largesize -int "128" && killall Dock
defaults write com.apple.dock "mineffect" -string "genie" && killall Dock
defaults write com.apple.dock "autohide" -bool "true" && killall Dock
defaults write com.apple.dock "autohide-time-modifier" -float "0.45" && killall Dock
defaults write com.apple.dock "autohide-delay" -float "0.2" && killall Dock
The next one is Finder where on Finder, the default display behaviour of not showing the folder paths and status bar when navigating always been the major pain point for me. I don’t like seeing myself getting lost every time I want to find something that I want.
So to sort that out, I do the following:
defaults write com.apple.finder ShowPathBar -bool true && killall Finder
defaults write com.apple.finder ShowStatusBar -bool true && killall Finder
And sometimes it would useful to toggle on/off hidden system files fro view on Macbook when I want to verify my local development settings, so I use the following:
defaults write com.apple.finder "AppleShowAllFiles" -bool "false" && killall Finder # to hide system files
defaults write com.apple.finder "AppleShowAllFiles" -bool "true" && killall Finder # to show system files
For more macbook.defaults
override customisations you desire, you can follow above links I provided earlier.
Conclusion
That’s it! I’ve shown you all the cool tricks you can use to speed up things up as much as possible with Bre, macbook.defaults ,etc. You can also find from my Gist profile here as if you need reference on the CLI commands I use for local development.
That’s the complete setup guide for my new Macbook M2 Pro for development as a start.
The next steps is transfer all of your Macbook software licences like MS Office, Alfred, Bartender etc from the old to the new. But you can do that in your pace at any time, if you’re not in the hurry to rush transferring them across.
Hope that’s been incredibly helpful for you.
Here’s to the new exciting chapter of software development experience for the new year of 2024 to come!
Till then, Happy Coding! 👩💻👨💻💪🖥