I recently got a new MacBook and procrastinated setting it up for a few days. Installing apps individually and configuring your machine manually feels like a huge chore.
I also don't want to bring the trash from the previous machines with the Time Machine feature. I like to start fresh each time. If something is important enough, it'll find its way to the new machine.
After posting the following on X and doing some research, I learned about the Brewfile and macOS defaults.
I'm procrastinating setting up my new Mac because I don't want to install apps one by one.
I want to create some bash scripts to automate the process, but I'm not familiar with bash scripting.
The Brewfile allows you to install command line utilities, applications, fonts and even Visual Studio Code (and forks/variants) extensions in bulk rather than installing them one by one.
You can create the Brewfile in the root directory of your machine and run brew bundle once you're done with it.
The bundle command installs all the things you specified in the file.
Settings defaults
macOS also provides the defaults utility to customize the settings of your MacBooks and certain applications.
Instead of updating the settings through the UI, you can achieve the same things by using the defaults utility in the terminal.
# Enable tap-to-click for the trackpad and show the correct state in System Preferences
defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true
defaults -currentHost write -g com.apple.mouse.tapBehavior -int 1
# Disable the .DS file creation
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
# Show the path bar in the Finder
defaults write com.apple.finder "ShowPathbar" -bool "true" && killall Finder
# Show hidden files in the Finder
defaults write com.apple.finder "AppleShowAllFiles" -bool "false" && killall Finder
# Keep folders on top in Finder
defaults write com.apple.finder "_FXSortFoldersFirst" -bool "true" && killall Finder
# Keep folders on top on Desktop
defaults write com.apple.finder "_FXSortFoldersFirstOnDesktop" -bool "true" && killall Finder
# Apply the settings
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u
This is very handy because you don't have to make all the changes manually.
Git - a plugin that provides useful Git shortcuts like gco instead of git checkout, for example.
Zsh-autosuggestions - autocomplete functionality based on your history of previous commands.
Zsh-syntax-highlighting - syntax highlighting for the commands you type in the terminal.
You-should-use - it reminds you of your aliases (shortcuts) when you use the full command. If you use git checkout instead of gco, it'll display the alias for the command, for example.
Zsh-bat - it improves the output of the cat command.
Zsh Aliases for Terminal Productivity
I use a handful of Zsh aliases (shortcuts) to save a few keystrokes and improve my terminal productivity.
What's Next
Create bash scripts to easily run the installation and commands
Add more commands
If you have any suggestions or feedback, please leave a comment.
If you like this content and it helped you, please consider supporting this blog.
When you search for "dotfiles" on GitHub, you'll find plenty of good script examples for setting up a new computer. Since Apple doesn't provide good documentation on what you can configure with "defaults" variables, these examples are a goldmine.
I moved all my setup to Ansible about five years ago. It’s been awesome, especially as it makes it trivial to replicate changes to new machines. Installed a new package? Run the playbook again. Changed a script? Run the playbook again.
Sure, there are edge cases I hit because I have some older machines, but for the most part, it’s awesome. I’m up and running on new Macs within a coffee break of getting terminal access.
This is the ideal version of the playbook I've been wanting to write for years to automate the chaotic dotfile collection I've written over the last 15 years!
The interface also allow to comment, post and interact with the original HN platform. Credentials are stored locally and are never sent to any server, you can check the source code here: https://github.com/GabrielePicco/hacker-news-rich.