Skip to content

Commit

Permalink
Install commandline tools, brew, extend manual steps
Browse files Browse the repository at this point in the history
  • Loading branch information
will-gant committed Aug 6, 2022
1 parent f4f7230 commit 8b13f3d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 7 deletions.
42 changes: 38 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# Mac setup

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

## Manual steps:
```bash
setup_repo="$(mktemp -d)"
zipball_url="$(curl -s https://api.github.com/repos/will-gant/mac-setup/releases/latest | grep zipball_url | cut -d '"' -f 4)"
zip_file="${setup_repo}/repo.zip"
curl --location "$zipball_url" --output "${setup_repo}/repo.zip"
unzip "$zip_file" -d "$setup_repo"
bash "$setup_repo/*mac-setup*/setup.sh
```
These should be run _after_ running the setup script.
## Manual steps:
These should be run _after_ the setup script completes.
### Git
1. Retrieve SSH private key from password manager
1. Copy into ~/.ssh/id_rsa
1. Copy it into ~/.ssh/id_rsa
1. Run `eval "$(ssh-agent -s)"`
1. Run `ssh-add --apple-use-keychain ~/.ssh/id_rsa`
Expand All @@ -20,3 +28,29 @@ Import `iterm2.json` as a profile via the iterm GUI
### VScode
Switch on 'sync' and login with GitHub
### System settings
NB. These take effect after a restart
```bash
# keyboard
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleCurrentKeyboardLayoutInputSourceID "com.apple.keylayout.British"
sudo defaults write /Library/Preferences/com.apple.HIToolbox AppleDefaultAsciiInputSource -dict InputSourceKind "Keyboard Layout" "KeyboardLayout ID" -int 2 "KeyboardLayout Name" British
sudo defaults delete /Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources
# updates
sudo defaults write /Library/Preferences/com.apple.commerce AutoUpdate -bool true
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate ConfigDataInstall -bool true
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate CriticalUpdateInstall -bool true
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticDownload -bool true
sudo defaults delete /Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources
sudo defaults write /Library/Preferences/com.apple.commerce AutoUpdateRestartRequired -bool true
# enable firewall
sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 2
# enable FileVault encryption (interactive)
sudo fdesetup enable
```
22 changes: 19 additions & 3 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
#!/usr/bin/env bash

set -e
set -eo pipefail

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

# commandline developer tools
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
xcode_version="$(softwareupdate --list | grep -E --only-matching "Command Line Tools for Xcode-[0-9]+\.[0-9]+" | tail -n 1)"
softwareupdate --install "$xcode_version" --verbose
rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress

# brew
mkdir "${script_dir}/homebrew" && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C "${script_dir}/homebrew"
eval "$(homebrew/bin/brew shellenv | tee "${HOME}/.zshrc")"
brew update --force --quiet
chmod -R go-w "$(brew --prefix)/share/zsh"

brew bundle --file="${script_dir}/Brewfile"
mkdir -p "${HOME}/Library/LaunchAgents"
brew autoupdate start 43200

# git
cp "${script_dir}/gitconfig" "${HOME}/.gitconfig"
Expand Down Expand Up @@ -34,9 +48,11 @@ mkdir -p "${ssh_dir}"
touch "${ssh_dir}/id_rsa"
chmod 400 "${ssh_dir}/id_rsa"

cat <<EOF > ${HOME}/.ssh/config
cat <<EOF > "${HOME}/.ssh/config"
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
EOF
EOF

mkdir -p "${HOME}/Workspace"

0 comments on commit 8b13f3d

Please sign in to comment.