macOS のセットアップ

リセット

  • SMC: 左Ctl+左Option+右Shift+Power(7秒) https://support.apple.com/ja-jp/HT201295
  • PRAM(NVRAM): 電源投入後 Command+Option+P+R(20秒) https://support.apple.com/ja-jp/HT204063

nvram 設定

起動音を消す。

sudo nvram StartupMute=%01

設定

ネットワークドライブで .DS_Store を作成しない。

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

US でキーリピートさせる。

defaults write -g ApplePressAndHoldEnabled -bool false

キーボード

  • Keyboard > Move focus to next window : Opt+Tab
  • Input Sources > Select next source in input menu : Command+~

アプリ

Homebrew

https://brew.sh/

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install cask
brew update
brew upgrade

シェル・ターミナルの設定

シェルを変更

chsh -s /bin/bash

bash-git-promot をインストール

brew install bash-completion
brew install bash-git-prompt
brew install iterm2

~/.bash_profile に追記

export BASH_SILENCE_DEPRECATION_WARNING=1

export EDITOR=vim

# bash-completion
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"

# git-bash-prompt
if [ -f "/usr/local/opt/bash-git-prompt/share/gitprompt.sh" ]; then
  __GIT_PROMPT_DIR="/usr/local/opt/bash-git-prompt/share"
  source "/usr/local/opt/bash-git-prompt/share/gitprompt.sh"
fi

各種ツール・アプリ

brew install terraform
brew install virtualbox vagrant
brew install plantuml graphviz

Java

brew install java
brew tap AdoptOpenJDK/openjdk
brew install adoptopenjdk11

~/.bash_profile に追記

# Java
export JAVA_HOME=$(/usr/libexec/java_home -v "11")
export PATH=${JAVA_HOME}/bin:$PATH

Python (pyenv)

brew install pyenv
pyenv install 3.8.7
pyenv global 3.8.7

Big Sur でエラーになる場合は以下を試す。

LDFLAGS="-L$(xcrun --show-sdk-path)/usr/lib" pyenv install 3.8.7

~/.bash_profile に追記

# pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

パッケージのインストール

pip install -U pip
pip install awsebcli
pip install aws-sam-cli
pip install cfn-lint
pip install mkdocs mkdocs-material

Node.js (nvm)

brew install nvm

~/.bash_profile に追記

# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion

LTS 版を使用する

nvm install --lts --latest-npm
nvm alias default lts/*

PHP

brew install php@7.4

~/.bash_profile に追記

# PHP
export PATH="/usr/local/opt/php@7.4/bin:$PATH"
export PATH="/usr/local/opt/php@7.4/sbin:$PATH"

AWS CLI

curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /

Amazon ECS CLI

sudo curl -Lo /usr/local/bin/ecs-cli https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-darwin-amd64-latest
sudo chmod +x /usr/local/bin/ecs-cli

その他

Ricty

brew tap sanemat/font
brew install ricty
cp -f /usr/local/opt/ricty/share/fonts/Ricty*.ttf ~/Library/Fonts/
fc-cache -vf

その他 (必要に応じて)