Open 0xdevalias opened 4 years ago
macOS Ventura 13.2.1
Go through the macOS installer, configure any settings as desired:
Once you've booted into macOS for the first time, it probably makes sense to check for any system updates (particularly major OS updates) and install those before continuing.
At this stage, it may also be useful to get a snapshot of the default configurations on a freshly installed version of macOS. This can be useful for updating the scripts that configure macOS defaults
(see 'dotfiles' section below)
Open Terminal and run the following:
mkdir ~/Desktop/macOS-defaults/
mkdir ~/Desktop/macOS-defaults/domains
defaults read > ~/Desktop/macOS-defaults/defaults-read.txt
defaults domains > ~/Desktop/macOS-defaults/defaults-domains.txt
defaults export -globalDomain - > ~/Desktop/macOS-defaults/defaults-export-globalDomain.xml
Then to export each individual domain's settings as .xml
files, we can use the following script:
#!/bin/bash
# ChatGPT Ref: https://chat.openai.com/chat/c03c1acf-5ba2-46a1-878e-020bb4715df6
# Define the output directory
output_dir="$HOME/Desktop/macOS-defaults/domains"
# Get a list of all domains
domains=$(defaults domains)
echo "Exporting domains..."
# Loop through each domain
IFS=", "
for domain in $domains; do
# Export the domain to an XML file
echo " $domain"
defaults export "$domain" - > "${output_dir}/${domain}.xml"
done
This will generally be performed as part of the Homebrew install script (see below), but if you want to do it manually, you can do this now (it's required for the default system installations of tools such as git
, etc)
xcode-select --install
If you try to run a command line tool such as git
before installing this, you will see a message similar to the following:
xcode-select
: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
Homebrew is a package manager that makes it easy to install all of the other applications we want on our machine.
It can be easily installed by opening Terminal and running the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
We used to have to manually set up the homebrew/cask
tap separately, but this is automatically included and enabled by default these days.
If you're setting up your new system while you still have your old one running, you can make use of macOS' Universal Control feature to share the same mouse/keyboard between both devices:
Use the keyboard, mouse or trackpad of your Mac to control up to two other nearby Mac or iPad devices and work seamlessly between them.
You can enable this by:
To make things easier, you probably also want to arrange your devices similar to how they are actually positioned in real life:
Once this is configured (potentially on both devices), you should be able to 'push' your pointer 'through' the edge of the screen from one device to the other.
0xdevalias/dotfiles
Once I have my basic bootstrap tools installed, I can clone my dotfiles repo, and run some more automated setup scripts to get my environment exactly how I like it.
Open Terminal and clone my dotfiles repo. Note that we use https
(rather than ssh
) to clone for now, as we don't have ssh keys setup on our new machine yet:
git clone https://github.com/0xdevalias/dotfiles.git ~/.dotfiles
~/.dotfiles/scripts/bootstrap
)Within Terminal, run the dotfiles bootstrap
script to configure git and symlink all of the dotfiles configuration into place:
~/.dotfiles/script/bootstrap
TODO: This should probably get moved into the bootstrap script so it happens automagically
sudo scutil --set ComputerName "newname"
(required)sudo scutil --set LocalHostName "newname"
(required)sudo scutil --set HostName "newname"
(probably not needed)dscacheutil -flushcache
(required?)scutil --get ComputerName
(was updated when I change computer name in system preferences)scutil --get LocalHostName
(was updated when I change computer name in system preferences)scutil --get HostName
("HostName: not set", even after configuring computer name in system preferences (but haven't restarted yet))TODO: This should probably get moved into the bootstrap script so it happens automagically
TODO: We should leverage the GitHub CLI (gh
) tool as much as possible here
script/bootstrap
ssh-keygen -t ed25519 -C "your_email@example.com" -f ~/.ssh/github_YOURUSERNAME_ed25519
cat ~/.ssh/github_devalias_ed25519.pub | pbcopy
(this will copy it to the clipboard)YOURUSERNAME@YOURCOMPUTERNAME.local
~/.dotfiles/ssh/keys.init
so that ssh-keyinit
works correctlyssh-add
github_USERNAME_ed25519 bitbucket_USERNAME_rsa gitlab_USERNAME_rsa
ssh-keyinit
once after restarting our machine, and it will load the specified keys for uscd ~/.dotfiles
git remote set-url origin git@github.com:0xdevalias/dotfiles.git
TODO: This should probably get moved into the bootstrap script so it happens automagically, since it's sort of a requirement for fully configuring git + commit signing properly
gpg
, pinentry-mac
):
~/.dotfiles/gpg/install.sh
TODO: This should probably get moved into the bootstrap script so it happens automagically, since it's sort of a semi-requirement for fully configuring git + commit signing properly I think
brew cask install keybase
keybase pgp list
keybase pgp pull-private THEGPGKEYID
(repeat for other keys as required)
signingkey
in ~/.dotfiles/git/gitconfig.local.symlink
gpg --list-secret-keys --keyid-format LONG
git config --file ~/.gitconfig.local --set user.signingkey THE16CHARKEYID
script/bootstrap
or similarAt this point it's worth closing and re-opening Terminal so that the configuration from the dotfiles can take effect.
TODO: Can we reload the shell automagically so we don't have to do it manually here..?
When the Terminal restarts, you might see some errors like the following, these are ok to ignore for now:
Loading antigen..
Error: No such keg: /opt/homebrew/Cellar/antigen
ERROR: Antigen not found. Was it installed with homebrew? Skipping. (/opt/homebrew/share/antigen/antigen.zsh, )
~/.dotfiles/starship.symlink/install.sh
)Our terminal isn't quite looking right yet as we're missing Starship, which manages our shell prompt customisations. We can install that now as follows:
~/.dotfiles/starship.symlink/install.sh
Once Starship is installed, close and re-open Terminal again, and now things should look more normal:
~/.dotfiles/sublimetext/install.sh
)Some of the next steps will be easier with a basic code/text editor installed, so we'll install Sublime Text next:
~/.dotfiles/sublimetext/install.sh
Make any customisations you may need before running. At a minimum, I would suggest checking that the latest versions are setup in:
TODO: continue things here
Continue setting up new laptop as per the main config steps detailed above
It would be cool to write about how I set up a new laptop, encoding some of my currently more manual processes, and the order that makes most sense in doing so.
Setting up a new laptop
Pre-Bootstrap
Go through the macOS installer, configure any settings as desired.
Once you've booted into macOS for the first time, it probably makes sense to check for any system updates (particularly major OS updates) and install those before continuing.
(Optional) At this stage, it may also be useful to get a snapshot of the default configurations on a freshly installed version of macOS. This can be useful for updating the scripts that configure macOS
defaults
(see 'dotfiles' section below)defaults read > ~/Desktop/macOS-defaults.txt
Bootstrap
(Optional) Install command line development tools.
This will generally be performed as part of the Homebrew install script (see below), but if you want to do it manually, you can do this now (it's required for the default system installations of tools such as
git
, etc)xcode-select --install
If you try to run a command line tool such as
git
before installing this, you will see a message similar to the following:Install Homebrew
Homebrew is a package manager that makes it easy to install all of the other applications we want on our machine.
It can be easily installed by opening Terminal and running the following command:
Once this is done, you probably also want enable the homebrew 'cask' 'tap', to be able to instal non CLI applications as well:
Dotfiles, defaults and core applications
Once I have my basic bootstrap tools installed, I can clone my dotfiles repo, and run some more automated setup scripts to get my environment exactly how I like it.
Open Terminal and clone my dotfiles repo. Note that we use
https
(rather thanssh
) to clone for now, as we don't have ssh keys setup on our new machine yet:Make any customisations you may need before running. At a minimum, I would suggest checking that the latest versions are setup in:
Note: I hit a number of issues when running this that we should figure how to fix:
After running the bootstrap, and restarting my terminal, it also seems as though it won't run all of the 'init scripts' correctly, due to missing programs, etc; which eventually cause the shell to exit with an error. These should either be included as part of a 'core required tools' step, or be smart enough to exit cleanly without running if those tools aren't already present:
If you see this, you can say
n
for the time being, then once your shell starts, run the following command to ensure the directories aren't world writeable:compaudit | xargs chmod g-w
Once everything is updated as desired, run
script/bootstrap
to install things:At time of writing, this will:
.gitconfig
*.symlink
files from the dotfiles repo into$HOME
bin/dot
whalebrew
and similar package management type things here too?antigen
is installedzsh
is installedNote that the automatic running of installs scripts is a little manual/haphazard at the moment, mostly because I don't necessarily want to automatically install everything on a new machine. I would suggest checking the code to see what will be run, and sanity checking that each is going to do what you want it to. A lot of these scripts end up being run once per new machine, so they can drift/become outdated from my 'ideal setup' over time.
Eventually I would like to clean this up and standardise it a bit more, to be a 'bare minimal' set (eg. core development environments for node, python, ruby, etc. Though I think when that happens, it may make sense to do so as part of adopting a dotfiles management tool (see https://github.com/0xdevalias/dotfiles/issues/8)
For now, refer to the below sections for a more 'manual' list of core installs/setup tasks for a new dev machine. I've roughly attempted to document them in the order I would follow, but this isn't necessarily a hard requirement.
Computer Name
sudo scutil --set ComputerName "newname"
(required)sudo scutil --set LocalHostName "newname"
(required)sudo scutil --set HostName "newname"
(probably not needed)dscacheutil -flushcache
(required?)scutil --get ComputerName
(was updated when I change computer name in system preferences)scutil --get LocalHostName
(was updated when I change computer name in system preferences)scutil --get HostName
("HostName: not set", even after configuring computer name in system preferences (but haven't restarted yet))Basic text/code editor
~/.dotfiles/sublimetext/install.sh
Generate SSH key for GitHub, GitLab, Bitbucket, etc
script/bootstrap
ssh-keygen -t ed25519 -C "your_email@example.com" -f ~/.ssh/github_YOURUSERNAME_ed25519
cat ~/.ssh/github_devalias_ed25519.pub | pbcopy
(this will copy it to the clipboard)YOURUSERNAME@YOURCOMPUTERNAME.local
~/.dotfiles/ssh/keys.init
so thatssh-keyinit
works correctlyssh-add
github_USERNAME_ed25519 bitbucket_USERNAME_rsa gitlab_USERNAME_rsa
ssh-keyinit
once after restarting our machine, and it will load the specified keys for uscd ~/.dotfiles
git remote set-url origin git@github.com:0xdevalias/dotfiles.git
Terminal/Shell (iTerm2)
~/.dotfiles/iterm2/install.sh
GPG (git commit signing, etc)
gpg
,pinentry-mac
):~/.dotfiles/gpg/install.sh
Keybase
brew cask install keybase
keybase pgp list
keybase pgp pull-private THEGPGKEYID
(repeat for other keys as required)signingkey
in~/.dotfiles/git/gitconfig.local.symlink
gpg --list-secret-keys --keyid-format LONG
git config --file ~/.gitconfig.local --set user.signingkey THE16CHARKEYID
script/bootstrap
or similarDevelopment Tools (Java, Node, Python, Ruby, Golang, Swift, Xcode, etc)
jenv
, etc):~/.dotfiles/java/install.sh
nodenv
, etc):~/.dotfiles/node/install.sh
pyenv
):~/.dotfiles/python/install.sh
rbenv
):~/.dotfiles/ruby/install.sh
goenv
)?swiftenv
)?brew cask install jetbrains-toolbox
~/.dotfiles/xcode/install.sh
(TODO: update this?)brew cask install sourcetree
(similar togitkraken
but free)/usr/local/bin/gpg
calledgpg2
ln -s /usr/local/bin/gpg /usr/local/bin/gpg2
Preferences -> Advanced -> GPG Program
/usr/local/bin
(it looks for a binary calledgpg2
in this folder)Repository -> Repository Settings -> Security
gpg2
binary as described abovebrew cask install gitkraken
(similar to SourceTree)brew cask install aws-vault
brew cask install docker
brew cask install postman
brew cask install insomnia
(optional, similar to postman)Web Browser
brew cask install google-chrome
brew cask install chrome-remote-desktop-host
Alfred
brew cask install alfred
Settings -> Advanced -> Syncing -> Set preferences folder
defaults read com.runningwithcrayons.Alfred
defaults read com.runningwithcrayons.Alfred-preferences
Settings -> General -> Alfred Hotkey
Settings -> Features -> Web Bookmarks
Settings -> Features -> Clipboard History
BetterTouchTool
brew cask install bettertouchtool
Dropbox -> Backup -> BetterTouchTool
)Default (THISCOMPUTER)
)Settings -> Standard Settings -> Basic -> Launch BetterTouchTool on Startup
Settings -> Advanced Settings -> General -> Enable automatic update checking
Settings -> Advanced Settings -> General -> Install Process Priority Helper Tool
Settings -> Advanced Settings -> Scripting BTT -> Allow External BetterTouchTool Scripting
Settings -> Advanced Settings -> Sync
Bartender
brew cask install bartender
Hyperdock
brew cask install hyperdock
Unsorted
The following don't have any complex setup scripts/environment required, so we can just manually install them with HomeBrew if desired:
brew cask install XXX
disk-inventory-x
flux
gemini
(duplicate file finder)viscosity
lastpass
dropbox
resilio-sync
fantastical
Preferences -> Accounts
Preferences -> Accounts -> Open maps in -> Google Maps
toggl
discord
signal
skype
telegram
zoomus
lastfm
(optional)plexamp
spotify
vlc
blackhole
native-access
soundflower
sidequest
sony-ps4-remote-play
steam
brew install XXX
(a small selection, seebrew.*.list
files for more)aria2
awscli
coreutils
dive
exiftool
ffmpeg
git
gnupg
go
gobuster
goreleaser
hub
jq
pcre
qemu
unrar
watchman
Unsorted
script/bootstrap
App Store
We also want to open the App Store, and install any past purchases we want on this machine:
Launchpad
Next we want to organise applications in Launchpad into appropriate folders. While this is controlled by a sqlite database, I'm not currently aware of any tools that allow us to do this automatically, so we'll do it manually for now:
Cleaning up an old laptop before selling/disposing
Unsorted
~/.netrc
~/.localrc
gpg --gen-revoke KEYID
gpg --import my_revocation.txt
gpg --keyserver pgp.mit.edu --send-keys KEYID
keybase pgp drop KEYBASEKEYID
Legacy