0
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

環境構築メモ(M1 Mac対応)

Last updated at Posted at 2022-08-18

これは何

Macを初期化したりすることがあるので、環境構築のメモです。

Macの初期設定

Macのパスワードを変更する

説明は特になし

AppleIDにサインインする

iCloud Drive 「デスクトップフォルダと書類フォルダ」にチェック

拡張子を表示する

上部メニューバーの「Finder」➡︎「環境設定」を開きます。Finder環境設定
環境設定メニューの「詳細」を選択し、「すべてのファイル名拡張子を表示」にチェックを入れます。

隠しファイルを表示する

隠しファイルを表示
defaults write com.apple.finder AppleShowAllFiles -bool true
ネットワークドライブ(NASとか)で .DS_Store を作成しないようにする
defaults write com.apple.desktopservices DSDontWriteNetworkStores True
Finderを再起動
killall Finder
workspaceフォルダを作成
mkdir ~/workspace
projectsフォルダを作成
mkdir ~/workspace/projects

Homebrew のインストール

https://brew.sh/ja/ の手順でインストールする

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo '# Set PATH, MANPATH, etc., for Homebrew.' >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
source ~/.zprofile
brew doctor

iTerm2 のインストール

brew install --cask iterm2

iTerm の設定を共有する

Settings > General > Load preferences from a custom folder or URL:

Default windowで開かないようにする

Settings > General > Startup
Only Restore Hotkey Window を選択

全画面表示にする

Settings > General > Window > Native full screen windows のチェックを外す
Settings > Profiles > Window > Settings for New Windows > Style, Screen, Space
Style: fullscreen
Screen: Screen with Cursor
Space: All spaces

背景を透過する

Settings > Profiles > Window
Transparency を30
Keep background colors opaque にチェック

ショートカットを設定

Settings > Keys > HotKey > Show/hide iTerm2 with a system-wide hotkey にチェック

タブを常時表示

Settings > Appearance > Tabs
Show tab bar even when there is only one tab にチェック

テーマを変更

Settings > Appearance > General
Theme を Dark

カラースキーマを変更

Settings > Profiles > Colors
Color Presets を Pastel (Dark Background)

warpも良さげ
brew install --cask warp

セキュリティソフトのインストール

brew install --cask eset-cyber-security

パスワード管理ツールのインストール

brew install --cask 1password
brew install --cask bitwarden

Xcode (XcodesApp) のインストール

複数バージョンのXcodeをインストールできるようにするため、XcodesAppをインストールする

brew install --cask xcodes

XcodesAppをインストール後、必要なXcodeをダウンロード&インストールする

手動でダウンロードする場合

Apple Developer - More Downloadからダウンロードする
※Appleのアカウントがあれば開発ライセンスは不要みたい

Xcodeの設定

※参考 https://qiita.com/zrn-ns/items/8493413e55b7329c023a

  1. スペルチェックを有効化
    メニューバー > Edit > Format > Spelling and Grammar > Check Spelling While Typing

  2. 空白文字を表示する
    メニューバー > Editor > Invisibles

  3. テーマの変更
    メニューバー > Editor > Theme
    Default (Dark)
    メニューバー > Xcode > Settings... > Generalタブ > Appearance
    Dark

  4. 行末スペースの自動削除設定
    メニューバー > Xcode > Settings... > Text Editingタブ > Editingタブ
    Automatically trim trailing whitespace
    including whitespace-only lines

  5. 改行目安(ガイド)を表示する
    メニューバー > Xcode > Settings... > Text Editingタブ > Displayタブ
    Page guide at column 120

  6. ビルドの成功/失敗時に効果音を鳴らす
    メニューバー > Xcode > Settings... > Behaviorsタブ
    Succeeds / Fails などを選択し、右の画面で Play sound
    Succeeds Breeze or Crystal
    Fails Funky or Pebble or Sonumi or Submerge

必要に応じて Network Link Conditioner をインストールする
Xcode のメニュー[Open Developer Tool] - [More Developer Tool]​​
参考
https://dev.classmethod.jp/articles/network-link-conditioner/

Google Chrom

brew install --cask google-chrome

インストール後、ログインして同期する

Github の設定

参考: 新しい SSH キーを生成して ssh-agent に追加する

公開鍵を作成

cd ~/.ssh
ssh-keygen -t ed25519 -C "your_email@example.com"
cat ~/.ssh/id_ed25519.pub | pbcopy

公開鍵をGitHubにアップする
https://github.com/settings/keys

バックグラウンドでssh-agentを開始

eval "$(ssh-agent -s)"

~/.ssh/config ファイルを作成して、キーが ssh-agent に自動的に読み込まれ、パスフレーズがキーチェーンに格納されるようにする

touch ~/.ssh/config
open ~/.ssh/config
Host github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

SSH 秘密鍵を ssh-agent に追加して、パスフレーズをキーチェーンに保存

ssh-add --apple-use-keychain ~/.ssh/id_ed25519

接続を確かめる

ssh -T git@github.com

上記の手順で作成したSSHキー(ed25519アルゴリズムを使用)をSourceTreeから読み込ませることはできないので、SourceTreeからは、GUIで直接さくせいする
参考: Sourcetree を使用して SSH を設定する

ghコマンドのインストール

brew install gh
echo 'eval "$(gh completion -s zsh)"' >> ~/.zshrc
source ~/.zshrc

Brewfile でアプリをインストール

既にインストールしているものはあるが、その他のアプリは、Brewfileでインストールする

% cd 【Brewfileがあるフォルダ】
% brew bundle

Brewfile

インストールが不要なものは、適時コメントアウト

Brewfile
# https://github.com/Homebrew/homebrew-bundle
#tap 'homebrew/bundle'
#tap 'homebrew/cask'
#tap 'homebrew/core'
#tap 'klaaspieter/formula'

# ----------------------------------------
# brew
# ----------------------------------------

#brew 'direnv'
#brew 'cocoapods'
#brew 'ruby-build'
#brew 'rbenv'
brew "mas"
#brew "chxcode"
#brew 'jq'
#brew 'mint'
#brew "java11"
#brew "gh"
#brew "nodebrew"
#brew "scrcpy"
#brew "ghq"
#brew "peco"
#brew "hub"
#brew "zsh-autosuggestions"
#brew "zsh-syntax-highlighting"
#brew "tmux"
#brew "gh"
brew "xcode-build-server"

# ----------------------------------------
# tap
# ----------------------------------------

# ----------------------------------------
# cask
# ----------------------------------------
# --------- priority ---------
cask 'iterm2'
cask '1password'
cask 'bitwarden'
cask 'google-chrome'
cask 'sublime-text'
cask 'keep'
cask 'xcodes'
cask 'sourcetree'
cask 'charles'
cask 'clipy'
cask 'adobe-creative-cloud'
#cask 'adobe-acrobat-reader'
#cask 'google-japanese-ime'
cask 'slack'
cask 'zoom'
#cask 'copilot-for-xcode'
#cask 'github-copilot-for-xcode'
#cask 'google-drive'

# --------- require ---------

# --- web browser
cask 'firefox'

# --- ide
cask 'android-studio'
cask 'visual-studio-code'

# --- dev tool
cask "sf-symbols"
#cask 'quicklook-json'
cask 'proxyman'

# --- other tool
cask 'the-unarchiver'
cask 'appcleaner'
cask 'microsoft-office'
cask 'miro'
cask 'figma'
#cask 'sketch'

# --------- optional ---------

# --- web browser
#cask 'brave'
cask 'adguard'

# --- ide tool'
#cask 'atom'

# --- dev tool
cask 'postman'
#cask 'sequel-ace'
#cask 'tableplus'
#cask 'docker'
#cask 'java'
cask 'drawio'
#cask 'vysor'
cask 'github'

# --- other tool
#cask 'kaleidoscope'
#cask 'xmind'
#cask 'coteditor'
#cask 'alfred'
#cask 'betterzipql'
#cask 'choosy'
#cask 'iconjar'
#cask 'mapture'
#cask 'qlmarkdown'
#cask 'qlstephen'
#cask 'rambox'
#cask 'openinterminal'
cask 'discord'
#graphviz
#librsvg
#plantuml


# brew cask alfred link

# ----------------------------------------
# mas
# ----------------------------------------

# IPAファイルをAppleデバイスに入れる
#mas 'Apple Configurator 2', id: 1037126344
# Xcode関係の不要ファイルを削除
mas 'DevCleaner', id: 1388020431
# パスワード管理マネージャー
#mas 'Bitwarden', id: 1352778147

mas 'Kindle', id: 302584613

# ----------------------------------------
# Font
# ----------------------------------------
#tap "homebrew/cask-fonts"

#cask "font-migu-1p"

※mas-cli(macコマンド)でのインストールは、Apple IDと紐付けるため一度App Storeから入手しておく必要があります。


以降は、必要に応じて

各種ツールのインストールと設定

ruby のインストール

rbenv もしくは asdf をインストール

rbenv のインストール

% brew install rbenv
% echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
% echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
% source ~/.zshrc
% rbenv install 3.1.3
% rbenv rehash
% rbenv global 3.1.3

asdf のインストール

brew install asdf
# 既存のバージョン管理ツールのファイル(例: .ruby-version, .node-version など)を参照するか
echo 'legacy_version_file = yes' >> ~/.asdfrc
echo '#asdf\nexport PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"' >> ~/.zshrc
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
asdf install ruby 3.1.3
asdf set ruby 3.1.3

direnv のインストール

% brew install direnv
% echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc
% source ~/.zshrc

各ブラウザの設定

Chrome「起動時 - 前回開いていたページを開く」
Safari「Safariの起動時 - 最後のセッションの全ウィンドウ」

GitHub Copilot for Xcode のインストール

参考: GitHub Copilot for Xcode

Sourcetree のインストール

brew install --cask sourcetree

設定値のバックアップをとっている場合

cd 【バックアップがあるフォルダ】
cp browser.plist ~/Library/Application\ Support/SourceTree/browser.plist

Atom の設定

Sync-Settingsを使って同期する

Markdownエディタの設定

Preferences... > Packages

  • markdown-preview
    ※ control + shift + mでプレビュー表示できる

  • Break On Single Newline

  • Use Github.com Style

  • markdown-scroll-sync

  • markdown-writer

  • tool-bar

  • tool-bar-markdown-writer

  • markdown-toc

  • wordcount

  • markdown-mindmap

  • atom-beautify

  • git-time-machine

  • minimap

StyleSheetに追記
Atom > スタイルシート

.markdown-preview {
  background: white !important;
  color: #192F60;
  p, h1, h2, h3, h4, h5, h6, li, th, td, strong {
    color: #192F60 !important;
  }
  h1 {border-bottom: solid 3px #E6E6E6; padding: 3px;}
  h2 {border-bottom: solid 2px #E6E6E6; padding: 3px;}
  h3 {border-left: solid 2px #E6E6E6; padding-left: 12px;}
}

xcode-install のインストール

複数バージョンのXcodeを共存させ、かんたんに切り替えて使えるツール
※ Xcodes or XcodesApp をインストールしている場合は不要

% gem install xcode-install
% export XCODE_INSTALL_USER=[developer account id]
% export XCODE_INSTALL_PASSWORD=[account password]
% xcversion list
% xcversion install [xcodeバージョン]
% xcversion installed
% xcversion select [Xcodeバージョン]
% xcversion selected

参考
https://sussan-po.com/2019/08/29/how-to-use-xcversion/

chxcode のインストール

複数バージョンのXcodeを自動で切り替える

% brew tap klaaspieter/formula
% brew install chxcode

~/.zshrc に以下を追加

~/.zshrc
echo 'source /opt/homebrew/share/chxcode/chxcode' >> ~/.zshrc
echo 'source /opt/homebrew/share/chxcode/auto' >> ~/.zshrc

環境によってパスが違う可能性があるのでbrew info chxcodeで要確認

nodebrewの初期設定

% nodebrew setup

nodebrew の PATH を通す

% vim ~/.zshrc
// 以下を追記する
// export PATH=$HOME/.nodebrew/current/bin:$PATH

% source ~/.zshrc

% nodebrew install stable
% nodebrew use stable

Firebase CLI をインストールする

% npm install -g firebase-tools
% firebase login

0
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?