LoginSignup
145
135

More than 5 years have passed since last update.

ターミナルから Mac を設定する(defaults write コマンド等)

Posted at

シェルスクリプトにそのまま書けるので、dotfiles に入れて、初期設定を自動化できます。

Dock

# Automatically hide or show the Dock (Dock を自動的に隠す)
defaults write com.apple.dock autohide -bool true
# Wipe all app icons from the Dock (Dock に標準で入っている全てのアプリを消す、Finder とごみ箱は消えない)
defaults write com.apple.dock persistent-apps -array
# Set the icon size (アイコンサイズの設定)
defaults write com.apple.dock tilesize -int 55
# Magnificate the Dock (Dock の拡大機能を入にする)
defaults write com.apple.dock magnification -bool true

Mission Control

# Hot corners (Mission Control のホットコーナーの設定)
# Possible values:
#  0: no-op
#  2: Mission Control
#  3: Show application windows
#  4: Desktop
#  5: Start screen saver
#  6: Disable screen saver
#  7: Dashboard
# 10: Put display to sleep
# 11: Launchpad
# 12: Notification Center
# Top left screen corner → Put display to sleep (左上 → ディスプレイをスリープ)
defaults write com.apple.dock wvous-tl-corner -int 10
defaults write com.apple.dock wvous-tl-modifier -int 0
# Top right screen corner → Desktop (右上 → デスクトップを表示)
defaults write com.apple.dock wvous-tr-corner -int 4
defaults write com.apple.dock wvous-tr-modifier -int 0
# Bottom left screen corner → Mission Control (左下 → Mission Control)
defaults write com.apple.dock wvous-bl-corner -int 2
defaults write com.apple.dock wvous-bl-modifier -int 0
# Bottom right screen corner → Show application windows (右下 → アプリケーションウィンドウ)
defaults write com.apple.dock wvous-br-corner -int 3
defaults write com.apple.dock wvous-br-modifier -int 0

QuickLook

# Allow you to select and copy string in QuickLook (QuickLook で文字の選択、コピーを出来るようにする)
defaults write com.apple.finder QLEnableTextSelection -bool true

私の環境(OS X 10.11 El Capitan クリーンインストール)だと、これが動かなくて困ってます。。。

Finder

# Automatically open a new Finder window when a volume is mounted
# マウントされたディスクがあったら、自動的に新しいウィンドウを開く
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true

# Set `${HOME}` as the default location for new Finder windows
# 新しいウィンドウでデフォルトでホームフォルダを開く
defaults write com.apple.finder NewWindowTarget -string "PfDe"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/"

# Show Status bar in Finder (ステータスバーを表示)
defaults write com.apple.finder ShowStatusBar -bool true

# Show Path bar in Finder (パスバーを表示)
defaults write com.apple.finder ShowPathbar -bool true

# Show Tab bar in Finder (タブバーを表示)
defaults write com.apple.finder ShowTabView -bool true

# Show the ~/Library directory (ライブラリディレクトリを表示、デフォルトは非表示)
chflags nohidden ~/Library

# Show the hidden files (不可視ファイルを表示)
defaults write com.apple.finder AppleShowAllFiles YES

Safari

# Enable the `Develop` menu and the `Web Inspector` (開発メニューを表示)
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true

# Enable `Debug` menu (メニュー → デバッグを表示)
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true

# Show the full URL in the address bar (note: this will still hide the scheme)
# アドレスバーに完全なURLを表示
defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true

# Add a context menu item for showing the `Web Inspector` in web views
# コンテキストメニューにWebインスペクタを追加
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true

# Show Safari's Status Bar (ステータスバーを表示)
defaults write com.apple.Safari ShowStatusBar -bool true

# Don't remember passwords (パスワードを自動入力・記録しない)
defaults write com.apple.Safari AutoFillPasswords -bool false

Terminal.app

Terminal.app で、カスタムテーマを作り、それを書き出して*.terminalファイル(ここでは、Solarized_Dark.terminal )を実行するシェルスクリプトと同じフォルダに入れておく。

# Use a custom theme (カスタムテーマを使う、そのテーマをデフォルトに設定する)
# Use a modified version of the Solarized Dark theme by default in Terminal.app
TERM_PROFILE='Solarized_Dark';
TERM_PATH='./';
CURRENT_PROFILE="$(defaults read com.apple.terminal 'Default Window Settings')";
if [ "${CURRENT_PROFILE}" != "${TERM_PROFILE}" ]; then
    open "$TERM_PATH$TERM_PROFILE.terminal"
    defaults write com.apple.Terminal "Default Window Settings" -string "$TERM_PROFILE"
    defaults write com.apple.Terminal "Startup Window Settings" -string "$TERM_PROFILE"
fi
defaults import com.apple.Terminal "$HOME/Library/Preferences/com.apple.Terminal.plist"

Spotlight

# Load new settings before rebuilding the index (インデックスを再構築する前に新しい設定を読み込む)
killall mds > /dev/null 2>&1
# Make sure indexing is enabled for the main volume (メインディスクのインデックスを有効にする)
sudo mdutil -i on / > /dev/null
# Rebuild the index from scratch (インデックスを最初から再構築)
sudo mdutil -E / > /dev/null

Trackpad

# Enable `Tap to click` (タップでクリックを有効にする)
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1

# Map bottom right Trackpad corner to right-click (右下をクリックで、副クリックに割り当てる)
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadCornerSecondaryClick -int 2
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool true
defaults -currentHost write NSGlobalDomain com.apple.trackpad.trackpadCornerClickBehavior -int 1
defaults -currentHost write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -bool true

その他の設定

# Avoid creating `.DS_Store` files on network volumes (ネットワークディスクで、`.DS_Store` ファイルを作らない)
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

# Hide the battery percentage from the menu bar (バッテリーのパーセントを非表示にする)
defaults write com.apple.menuextra.battery ShowPercent -string "NO"

# Date options: Show the day of the week: on (日付表示設定、曜日を表示)
defaults write com.apple.menuextra.clock 'DateFormat' -string 'EEE H:mm'

# Disable the "Are you sure you want to open this application?" dialog
# 未確認のアプリケーションを実行する際のダイアログを無効にする
defaults write com.apple.LaunchServices LSQuarantine -bool false

# Automatically quit the printer app once the print jobs are completed
# 印刷が終了したら、自動的にプリンターアプリを終了する
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true

# Save screenshots as PNGs (スクリーンショット保存形式をPNGにする)
defaults write com.apple.screencapture type -string "png"

# Require password immediately after the computer went into
# sleep or screen saver mode (スリープまたはスクリーンセーバから復帰した際、パスワードをすぐに要求する)
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0

# Expand save panel by default (保存パネルをデフォルトで開いた状態にする)
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true

# Expand print panel by default (印刷パネルをデフォルトで開いた状態にする)
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true

# Hide the Time Machine and Volume icons from the menu bar (メニューバーのTime Machine と音量アイコンを非表示にする)
for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do
    sudo defaults write "${domain}" dontAutoLoad -array \
        "/System/Library/CoreServices/Menu Extras/TimeMachine.menu" \
        "/System/Library/CoreServices/Menu Extras/Volume.menu"
done

最後に

以上が、個人的な設定ですが、mathiasbynens さんの、.osx が、割とまとまって色んな事設定してました。
さらに、それを解説している、勝手に独り読書会 - その01 - ばかもりだし も「その08」まであって、全部参考になります。

145
135
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
145
135