Skip to content

Commit 8b13f3d

Browse files
committed
Install commandline tools, brew, extend manual steps
1 parent f4f7230 commit 8b13f3d

File tree

2 files changed

+57
-7
lines changed

2 files changed

+57
-7
lines changed

README.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
# Mac setup
22

3-
Run `./setup.sh`
3+
Run the following to download the latest release of this repo and then run the setup script:
44

5-
## Manual steps:
5+
```bash
6+
setup_repo="$(mktemp -d)"
7+
zipball_url="$(curl -s https://api.github.com/repos/will-gant/mac-setup/releases/latest | grep zipball_url | cut -d '"' -f 4)"
8+
zip_file="${setup_repo}/repo.zip"
9+
curl --location "$zipball_url" --output "${setup_repo}/repo.zip"
10+
unzip "$zip_file" -d "$setup_repo"
11+
bash "$setup_repo/*mac-setup*/setup.sh
12+
```
613
7-
These should be run _after_ running the setup script.
14+
## Manual steps:
815
16+
These should be run _after_ the setup script completes.
917
### Git
1018
1119
1. Retrieve SSH private key from password manager
12-
1. Copy into ~/.ssh/id_rsa
20+
1. Copy it into ~/.ssh/id_rsa
1321
1. Run `eval "$(ssh-agent -s)"`
1422
1. Run `ssh-add --apple-use-keychain ~/.ssh/id_rsa`
1523
@@ -20,3 +28,29 @@ Import `iterm2.json` as a profile via the iterm GUI
2028
### VScode
2129
2230
Switch on 'sync' and login with GitHub
31+
32+
### System settings
33+
34+
NB. These take effect after a restart
35+
36+
```bash
37+
# keyboard
38+
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleCurrentKeyboardLayoutInputSourceID "com.apple.keylayout.British"
39+
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleDefaultAsciiInputSource -dict InputSourceKind "Keyboard Layout" "KeyboardLayout ID" -int 2 "KeyboardLayout Name" British
40+
sudo defaults delete /Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources
41+
42+
# updates
43+
sudo defaults write /Library/Preferences/com.apple.commerce AutoUpdate -bool true
44+
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate ConfigDataInstall -bool true
45+
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate CriticalUpdateInstall -bool true
46+
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true
47+
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticDownload -bool true
48+
sudo defaults delete /Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources
49+
sudo defaults write /Library/Preferences/com.apple.commerce AutoUpdateRestartRequired -bool true
50+
51+
# enable firewall
52+
sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 2
53+
54+
# enable FileVault encryption (interactive)
55+
sudo fdesetup enable
56+
```

setup.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
#!/usr/bin/env bash
22

3-
set -e
3+
set -eo pipefail
44

55
script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
66

7+
# commandline developer tools
8+
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
9+
xcode_version="$(softwareupdate --list | grep -E --only-matching "Command Line Tools for Xcode-[0-9]+\.[0-9]+" | tail -n 1)"
10+
softwareupdate --install "$xcode_version" --verbose
11+
rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
12+
13+
# brew
14+
mkdir "${script_dir}/homebrew" && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C "${script_dir}/homebrew"
15+
eval "$(homebrew/bin/brew shellenv | tee "${HOME}/.zshrc")"
16+
brew update --force --quiet
17+
chmod -R go-w "$(brew --prefix)/share/zsh"
18+
719
brew bundle --file="${script_dir}/Brewfile"
20+
mkdir -p "${HOME}/Library/LaunchAgents"
21+
brew autoupdate start 43200
822

923
# git
1024
cp "${script_dir}/gitconfig" "${HOME}/.gitconfig"
@@ -34,9 +48,11 @@ mkdir -p "${ssh_dir}"
3448
touch "${ssh_dir}/id_rsa"
3549
chmod 400 "${ssh_dir}/id_rsa"
3650

37-
cat <<EOF > ${HOME}/.ssh/config
51+
cat <<EOF > "${HOME}/.ssh/config"
3852
Host *
3953
AddKeysToAgent yes
4054
UseKeychain yes
4155
IdentityFile ~/.ssh/id_rsa
42-
EOF
56+
EOF
57+
58+
mkdir -p "${HOME}/Workspace"

0 commit comments

Comments
 (0)