Skip to content

Instantly share code, notes, and snippets.

@antonydevanchi
Forked from blendthink/setup_for_mac.sh
Created August 31, 2021 23:49
Show Gist options
  • Save antonydevanchi/b9868dc2431a292e8a45b878b7730622 to your computer and use it in GitHub Desktop.
Save antonydevanchi/b9868dc2431a292e8a45b878b7730622 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# 実行方法
#
# Mac のターミナルで以下を入力して実行
# sh -c "$(curl -fsSL https://gist.github.com/blendthink/5ca7dd072db6b0ebe5af8189d2cc5aad/raw)"
#
# 公式のドキュメントは以下
# https://developer.apple.com/documentation/technologies
#
# 現在の設定を抜き出すのに便利なツール
# https://github.com/aerobounce/defaults.sh
# 設定アプリを終了
killall System\ Preferences
# Google Chrome を終了
killall Google\ Chrome
# Google Chrome をデフォルトの Web ブラウザにするか確認ダイアログを表示する
open -a "Google Chrome" --args --make-default-browser
# ------------------
# defaults
# ------------------
# ------------------
# グローバルな設定
# ------------------
defaults write -g AppleActionOnDoubleClick -string "None" # ウインドウタイトルバーのダブルクリックでしまわない
defaults write -g AppleEnableSwipeNavigateWithScrolls -bool true # スワイプで戻る・進むを有効にする
defaults write -g AppleInterfaceStyle -string "Dark" # ダークモード
defaults write -g AppleMiniaturizeOnDoubleClick -bool false # ダブルクリックで小型化しない
defaults write -g AppleScrollerPagingBehavior -bool true # スクロールバーのクリック時にクリックされた場所へジャンプ
defaults write -g AppleShowAllExtensions -int 1 # 拡張子を常に表示
defaults write -g AppleShowScrollBars -string "Always" # スクロールバーの常時表示
defaults write -g AppleSpacesSwitchOnActivate -int 0 # アプリケーションの切り替えで、アプリケーションのウインドウが開いている操作スペースに移動しない
defaults write -g NSAutomaticCapitalizationEnabled -int 0 # 自動大文字の無効
defaults write -g NSAutomaticDashSubstitutionEnabled -int 0 # ダッシュ置換を無効
defaults write -g NSAutomaticPeriodSubstitutionEnabled -int 0 # 自動ピリオド置換を無効
defaults write -g NSAutomaticQuoteSubstitutionEnabled -int 0 # スマートクォートを無効
defaults write -g NSAutomaticSpellingCorrectionEnabled -int 0 # 自動スペル置換を無効
defaults write -g NSAutomaticTextCompletionEnabled -int 0 # 自動テキスト補完を無効
defaults write -g NSAutomaticWindowAnimationsEnabled -bool false # ファイルを開くときのアニメーションを無効
defaults write -g NSInitialToolTipDelay -int 0 # ツールチップが表示される時間をなしに設定
defaults write -g NSWindowResizeTime -float 0.001 # コンソールアプリケーションの画面サイズ変更を高速にする
defaults write -g WebAutomaticSpellingCorrectionEnabled -int 0 # Web の自動スペル置換を無効
# springing
defaults write -g com.apple.springing.delay -float 0 # スプリングロード遅延を除去
defaults write -g com.apple.springing.enabled -bool true # ディレクトリのスプリングロードを有効化
# trackpad
defaults write -g com.apple.trackpad.forceClick -bool false # forceClick を無効
defaults write -g com.apple.trackpad.scrolling -float 0.5882 # スクロール速度を自分好みに
defaults write -g com.apple.trackpad.scaling -int 3 # トラックパッドの軌跡の速さを最大に設定
# ------------------
# ローカルな設定
# ------------------
# Trackpad
defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true # トラックパッドタップを有効
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -bool true # 三本指のドラッグを有効
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerHorizSwipeGesture -int 0 # 三本指の横方向のジェスチャーを無効
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerVertSwipeGesture -int 0 # 三本指の縦方向のジェスチャーを無効
# BluetoothTrackpad Trackpad と同じものを設定
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerHorizSwipeGesture -int 0
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerVertSwipeGesture -int 0
# 残りはデフォルト値
defaults write com.apple.AppleMultitouchTrackpad ActuateDetents -int 1
defaults write com.apple.AppleMultitouchTrackpad DragLock -int 0
defaults write com.apple.AppleMultitouchTrackpad Dragging -int 0
defaults write com.apple.AppleMultitouchTrackpad FirstClickThreshold -int 1
defaults write com.apple.AppleMultitouchTrackpad ForceSuppressed -int 0
defaults write com.apple.AppleMultitouchTrackpad SecondClickThreshold -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadCornerSecondaryClick -int 0
defaults write com.apple.AppleMultitouchTrackpad TrackpadFiveFingerPinchGesture -int 2
defaults write com.apple.AppleMultitouchTrackpad TrackpadFourFingerHorizSwipeGesture -int 2
defaults write com.apple.AppleMultitouchTrackpad TrackpadFourFingerPinchGesture -int 2
defaults write com.apple.AppleMultitouchTrackpad TrackpadFourFingerVertSwipeGesture -int 2
defaults write com.apple.AppleMultitouchTrackpad TrackpadHandResting -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadHorizScroll -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadMomentumScroll -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadPinch -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadRightClick -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadRotate -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadScroll -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerTapGesture -int 0
defaults write com.apple.AppleMultitouchTrackpad TrackpadTwoFingerDoubleTapGesture -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadTwoFingerFromRightEdgeSwipeGesture -int 3
defaults write com.apple.AppleMultitouchTrackpad USBMouseStopsTrackpad -int 0
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad DragLock -int 0
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Dragging -int 0
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadCornerSecondaryClick -int 0
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadFiveFingerPinchGesture -int 2
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadFourFingerHorizSwipeGesture -int 2
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadFourFingerPinchGesture -int 2
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadFourFingerVertSwipeGesture -int 2
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadHandResting -int 1
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadHorizScroll -int 1
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadMomentumScroll -int 1
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadPinch -int 1
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -int 1
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRotate -int 1
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadScroll -int 1
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerTapGesture -int 0
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadTwoFingerDoubleTapGesture -int 1
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadTwoFingerFromRightEdgeSwipeGesture -int 3
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad USBMouseStopsTrackpad -int 0
# TextEdit
defaults write com.apple.TextEdit AddExtensionToNewPlainTextFiles -bool false # 新規テキストファイル作成時に拡張子を追加しない
defaults write com.apple.TextEdit CheckSpellingWhileTyping -bool false # タイピング中にスペルをチェックしない
defaults write com.apple.TextEdit CheckGrammarWithSpelling -bool false # スペルで文法チェクを無効
defaults write com.apple.TextEdit CorrectSpellingAutomatically -bool false # 自動スペル修正を無効
defaults write com.apple.TextEdit IgnoreHTML -bool true # HTML を無効
defaults write com.apple.TextEdit IgnoreRichText -bool true # リッチテキストを無効
defaults write com.apple.TextEdit PlainTextEncoding -int 4 # ファイルを開くときのエンコーディングを UTF-8
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4 # ファイルを保存するときのエンコーディングを UTF-8
defaults write com.apple.TextEdit RichText -bool false # リッチテキストを無効
defaults write com.apple.TextEdit ShowRuler -bool false # ルーラ非表示
defaults write com.apple.TextEdit SmartCopyPaste -bool false # スマートコピー/ペーストを無効
defaults write com.apple.TextEdit SmartDashes -bool false # スマートダッシュ記号を無効
defaults write com.apple.TextEdit SmartQuotes -bool false # スマート引用符を無効
defaults write com.apple.TextEdit TextReplacement -bool false # テキストの変換を無効
# TextInputMenu
defaults write com.apple.TextInputMenu visible -bool true # テキストインプットメニューを表示
# TextInputMenuAgent
defaults write com.apple.TextInputMenuAgent "NSStatusItem Visible Item-0" -bool true # メニューバーに現在ステータス項目を表示
# Dock
defaults write com.apple.dock autohide -bool true # Dock を自動的に非表示
defaults write com.apple.dock autohide-delay -float 0 # Dock をすぐに表示する
defaults write com.apple.dock launchanim -bool false # アプリケーションを開くアニメーションを無効
defaults write com.apple.dock mineffect -string "genie" # 最小化する時のエフェクトを genie にする
defaults write com.apple.dock mod-count -int 12 # Dock 変更カウント
defaults write com.apple.dock mru-spaces -bool false # スペースを最近の使用状況によって自動的にソートしない
defaults write com.apple.dock orientation -string "bottom" # Dock を下に配置
defaults write com.apple.dock persistent-apps -array # 一度 Dock に追加されているアプリを削除
defaults write com.apple.dock show-process-indicators -bool true # Dock で開いているアプリケーションのプロセスインジケーターを表示する
defaults write com.apple.dock show-recents -bool false # 最近のアプリを非表示
defaults write com.apple.dock showAppExposeGestureEnabled -bool true # 4 本指で下にスワイプすると、使用中のアプリケーションのウインドウがすべて表示
defaults write com.apple.dock tilesize -int 35 # 小さめに表示
defaults write com.apple.dock wvous-br-corner -int 13 # 右下にマウスを移動すると画面をロックする
defaults write com.apple.dock wvous-br-modifier -int 0 # 右下のデフォルトの挙動を削除
# Finder
defaults write com.apple.finder AnimateWindowZoom -bool false # フォルダを開くときのアニメーションを無効
defaults write com.apple.finder AppleShowAllFiles -bool true # 隠しファイルを表示
defaults write com.apple.finder DisableAllAnimations -bool true # アニメーション効果を全て無効
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" # 検索をデフォルトでカレントディレクトリ以下にする
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false # 拡張子の変更を警告しない
defaults write com.apple.finder NSNavLastUserSetHideExtensionButtonState -bool true # 保存シートでファイル名拡張子を非表示にする
defaults write com.apple.finder NewWindowTarget -string "PfDe" # その他
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Downloads/" # 新規ウィンドウは Downloads で開く
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true # デスクトップに表示する項目 外部ディスク 表示
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false # デスクトップに表示する項目 ハードディスク(内蔵 SSD)非表示
defaults write com.apple.finder ShowPathbar -bool true # パスバー表示
defaults write com.apple.finder ShowRecentTags -bool false # 最近のタグ非表示
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool false # デスクトップに表示する項目 CD、DVD、iPod 表示
defaults write com.apple.finder ShowSidebar -bool true # スライドバー表示
defaults write com.apple.finder ShowStatusBar -bool true # ステータスバー表示
defaults write com.apple.finder ShowTabView -bool true # タブビュー表示
defaults write com.apple.finder SidebarDevicesSectionDisclosedState -bool true # 選択されているデバイスの状態を表示
defaults write com.apple.finder SidebarPlacesSectionDisclosedState -bool true # 選択されている場所の状態を表示
defaults write com.apple.finder SidebarShowingSignedIntoiCloud -bool true # iCloud にサインインしているかどうかを表示
defaults write com.apple.finder SidebarShowingiCloudDesktop -bool false # iCloud を非表示
defaults write com.apple.finder WarnOnEmptyTrash -bool false # ゴミ箱を空にする前の警告の無効化
defaults write com.apple.finder _FXSortFoldersFirst -bool true # 名前で並べ替えを選択時にディレクトリを前に置く
defaults write com.apple.finder _FXSortFoldersFirstOnDesktop -bool true # Desktop で名前で並べ替えを選択時にディレクトリを前に置く
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true # 絶対パスを表示
#
# NewWindowTarget の他の値
#
# PfCm : コンピュータ名
# PfVo : ルート(起動ボリューム)
# PfHm : ホームフォルダ
# PfDe : デスクトップ
# PfDo : 書類
# PfID : iCloud Drive
# PfAf : マイファイル
# PfLo : その他
#
# Finder iCloud 関連(全て無効)
#
# defaults write com.apple.finder FXEnableRemoveFromICloudDriveWarning -bool false
# defaults write com.apple.finder FXICloudDriveDeclinedUpgrade -bool false
# defaults write com.apple.finder FXICloudDriveDesktop -bool false
# defaults write com.apple.finder FXICloudDriveDocuments -bool false
# defaults write com.apple.finder FXICloudDriveEnabled -bool false
# defaults write com.apple.finder FXICloudDriveFirstSyncDownComplete -bool false
# Battery
defaults write com.apple.menuextra.battery ShowPercent -string "YES" # バッテリーのパーセントを表示
# Clock
defaults write com.apple.menuextra.clock DateFormat -string "M月d日(EEE) H:mm" # 月・日・曜日・時・分を表示
# NetworkConnect
defaults write com.apple.networkConnect VPNShowTime -bool true # VPN の接続時間を表示
# StatusItem
defaults write com.apple.systemuiserver "NSStatusItem Visible Siri" -bool false # Siri 非表示
defaults write com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.airplay" -bool true # airplay 表示
defaults write com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.airport" -bool true # airport 表示
defaults write com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.battery" -bool true # battery 表示
defaults write com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.bluetooth" -bool true # bluetooth 表示
defaults write com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.clock" -bool true # clock 表示
defaults write com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.volume" -bool true # volume 表示
defaults write com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.vpn" -bool true # vpn 表示
defaults write com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.appleuser" -bool true # appleuser 表示
# DS_Store
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true # ネットワークストレージで DS_Store を作成しない
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true # USB ストレージで DS_Store を作成しない
# CrashReporter
defaults write com.apple.CrashReporter DialogType -string "none" # クラッシュレポートを無効
# Terminal
defaults write com.apple.Terminal "Default Window Settings" -string "Homebrew" # デフォルトのスタイルを Homebrew
defaults write com.apple.Terminal "Startup Window Settings" -string "Homebrew" # 起動時のスタイルを Homebrew
defaults write com.apple.Terminal NewWindowSettingsBehavior -int 2 # 新規ウィンドウ 同じプロファイル
defaults write com.apple.Terminal NewWindowWorkingDirectoryBehavior -int 1 # 新規ウィンドウ デフォルト作業ディレクトリ
defaults write com.apple.Terminal NewTabWorkingDirectoryBehavior -int 2 # 新規タブ 同じ作業ディレクトリ
defaults write com.apple.Terminal NewTabSettingsBehavior -int 2 # 新規タブ 同じプロファイル
# ------------------
# defaults currentHost
# ------------------
defaults -currentHost write -g com.apple.mouse.tapBehavior -int 1 # タップでクリックを有効
defaults -currentHost write -g com.apple.trackpad.threeFingerDragGesture -int 1 # 三本指のドラッグを有効
defaults -currentHost write -g com.apple.trackpad.threeFingerHorizSwipeGesture -int 0 # 三本指の横方向のジェスチャーを無効
defaults -currentHost write -g com.apple.trackpad.threeFingerVertSwipeGesture -int 0 # 三本指の縦方向のジェスチャーを無効
# UserActivityD
defaults -currentHost write com.apple.coreservices.useractivityd ActivityAdvertisingAllowed -int 0 # Mac と iCloud デバイス間での Handoff を許可しない
defaults -currentHost write com.apple.coreservices.useractivityd ActivityReceivingAllowed -int 0 # Mac と iCloud デバイス間での Handoff を許可しない
# 変更したアプリを終了
killall Finder
killall Dock
# ------------------
# ディレクトリ作成
# ------------------
# 作成するディレクトリ一覧
directories=("Documents/temp" "Documents/repositories" ".ssh")
# ディレクトリが存在しなければ作成する
for directory in "${directories[@]}"
do
mkdir -p "$HOME/$directory"
done
# ------------------
# 認証用の設定
# ------------------
# chmod 700 ~/.ssh
# cd ~/.ssh || return
# ssh-keygen -t rsa
# chmod 400 ~/.ssh/id_github_rsa
# chmod 400 ~/.ssh/id_github_rsa.pub
# ssh-add ~/.ssh/id_github_rsa
# touch ~/.ssh/config
# chmod 600 ~/.ssh/config
# cat <<EOF >> ~/.ssh/config
# Host github
# HostName github.com
# IdentityFile ~/.ssh/id_github_rsa
# User git
# Port 22
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment