<commit_before>#!/bin/sh

# Close any open System Preferences panes, to prevent them from overriding
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# killall System\ Preferences

# Ask for the administrator password upfront
sudo -v

# Keep-alive: update existing `sudo` time stamp until this script has finished
# while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

# Change default shell from bash to zsh
if [[ $(dscl . -read /Users/$USER UserShell) = "UserShell: /bin/zsh" ]]; then
  :
else
  sudo dscl . -create /Users/$USER UserShell /bin/zsh
fi

#--------------------
# General
#--------------------

# Set dark mode
defaults write NSGlobalDomain AppleInterfaceStyle -string Dark

# Show scroll bar always
defaults write NSGlobalDomain AppleShowScrollBars -string Always

# 書類を閉じるときに変更内容を保持するかどうかを確認する
defaults write NSGlobalDomain NSCloseAlwaysConfirmsChanges -bool true

# アプリケーションを終了するときにウインドウを閉じず次回復元する
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool true

#--------------------
# Desktop & Screen Saver
#--------------------

# Disable screensaver
defaults -currentHost write com.apple.screensaver idleTime -int 0

# Hot corners (Bottom-Left, Show Desktop)
# NOTICE: if you put 'sudo' before commands, preferences may not be propagated correctly.
defaults write com.apple.dock wvous-bl-modifier -int 0
defaults write com.apple.dock wvous-bl-corner -int 4

#--------------------
# Dock
#--------------------

# magnification
defaults write com.apple.dock magnification -bool true

# size
defaults write com.apple.dock tilesize -int 40
defaults write com.apple.dock largesize -int 60

# Window title bar double click
defaults write NSGlobalDomain AppleActionOnDoubleClick -string Maximize

# Minimize to application
defaults write com.apple.dock minimize-to-application -bool true

# Disable launch animation
defaults write com.apple.dock launchanim -bool false

# Enable autohide
defaults write com.apple.dock autohide -bool true

# Show indicator
defaults write com.apple.dock show-process-indicators -bool true

# Show recents
defaults write com.apple.dock show-recents -bool true

# Remove the auto-hiding Dock delay
defaults write com.apple.dock autohide-delay -float 0
# Remove the animation when hiding/showing the Dock
defaults write com.apple.dock autohide-time-modifier -float 0

#--------------------
# Mission Control
#--------------------

#--------------------
# Language & Region
#--------------------

# 日付の書式設定等は変更のたびに下部の表示例を動的に変えているっぽい

#--------------------
# Security & Privacy
#--------------------

# May not be configurable by defaults command

#--------------------
# Spotlight
#--------------------

# TODO: excluding

#--------------------
# Notification
#--------------------

#--------------------
# Displays
#--------------------

# Enable HiDPI display modes (requires restart)
# ?
# sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true

# Show mirroring option on menu bar if available
defaults write com.apple.airplay showInMenuBarIfPresent -bool true

#--------------------
# Energy Saver
#--------------------

IS_LAPTOP=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Model Identifier" | grep "Book")
if [[ "$IS_LAPTOP" != "" ]]; then
  sudo pmset -b displaysleep 5 disksleep 10 sleep 15 lessbright 0 halfdim 1
  sudo pmset -c displaysleep 180 disksleep 0 sleep 0
else
  sudo pmset sleep 0 disksleep 0 displaysleep 180 halfdim 1
fi

#--------------------
# Keyboard
#--------------------

# Increase key repeat
defaults write NSGlobalDomain KeyRepeat -int 1

# Decrease key repeat delay

defaults write NSGlobalDomain InitialKeyRepeat -int 13

# Keyboard shortcut settings

# Switching to the next window
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 27 "<dict><key>enabled</key><true/><key>value</key><dict><key>parameters</key><array><integer>96</integer><integer>50</integer><integer>1048576</integer></array><key>type</key><string>standard</string></dict></dict>"

# input sources
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 60 "<dict><key>enabled</key><false/></dict>"
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 61 "<dict><key>enabled</key><true/><key>value</key><dict><key>parameters</key><array><integer>106</integer><integer>38</integer><integer>1048576</integer></array><key>type</key><string>standard</string></dict></dict>"

# Spotlight
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 64 "<dict><key>enabled</key><false/></dict>"

# IME setting seems to be difficult to configure by defaults command

#defaults write com.apple.HIToolbox AppleEnabledInputSources -array \
#'{ "Bundle ID" = "com.apple.PressAndHold"; InputSourceKind = "Non Keyboard Input Method"; }' \
#'{ "Bundle ID" = "com.google.inputmethod.Japanese"; "Input Mode" = "com.apple.inputmethod.Japanese"; InputSourceKind = "Input Mode"; }' \
#'{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 0; "KeyboardLayout Name" = "U.S."; }' \
#'{ "Bundle ID" = "com.google.inputmethod.Japanese"; InputSourceKind = "Keyboard Input Method"; }'

#defaults write com.apple.HIToolbox AppleInputSourceHistory -array \
#'{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 0; "KeyboardLayout Name" = "U.S."; }' \
#'{ "Bundle ID" = "com.google.inputmethod.Japanese"; "Input Mode" = "com.apple.inputmethod.Japanese"; InputSourceKind = "Input Mode"; }'<commit_msg>Update keyboard > text settings<commit_after>#!/bin/sh

# Close any open System Preferences panes, to prevent them from overriding
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# killall System\ Preferences

# Ask for the administrator password upfront
sudo -v

# Keep-alive: update existing `sudo` time stamp until this script has finished
# while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

# Change default shell from bash to zsh
if [[ $(dscl . -read /Users/$USER UserShell) = "UserShell: /bin/zsh" ]]; then
  :
else
  sudo dscl . -create /Users/$USER UserShell /bin/zsh
fi

#--------------------
# General
#--------------------

# Set dark mode
defaults write NSGlobalDomain AppleInterfaceStyle -string Dark

# Show scroll bar always
defaults write NSGlobalDomain AppleShowScrollBars -string Always

# 書類を閉じるときに変更内容を保持するかどうかを確認する
defaults write NSGlobalDomain NSCloseAlwaysConfirmsChanges -bool true

# アプリケーションを終了するときにウインドウを閉じず次回復元する
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool true

#--------------------
# Desktop & Screen Saver
#--------------------

# Disable screensaver
defaults -currentHost write com.apple.screensaver idleTime -int 0

# Hot corners (Bottom-Left, Show Desktop)
# NOTICE: if you put 'sudo' before commands, preferences may not be propagated correctly.
defaults write com.apple.dock wvous-bl-modifier -int 0
defaults write com.apple.dock wvous-bl-corner -int 4

#--------------------
# Dock
#--------------------

# magnification
defaults write com.apple.dock magnification -bool true

# size
defaults write com.apple.dock tilesize -int 40
defaults write com.apple.dock largesize -int 60

# Window title bar double click
defaults write NSGlobalDomain AppleActionOnDoubleClick -string Maximize

# Minimize to application
defaults write com.apple.dock minimize-to-application -bool true

# Disable launch animation
defaults write com.apple.dock launchanim -bool false

# Enable autohide
defaults write com.apple.dock autohide -bool true

# Show indicator
defaults write com.apple.dock show-process-indicators -bool true

# Show recents
defaults write com.apple.dock show-recents -bool true

# Remove the auto-hiding Dock delay
defaults write com.apple.dock autohide-delay -float 0
# Remove the animation when hiding/showing the Dock
defaults write com.apple.dock autohide-time-modifier -float 0

#--------------------
# Mission Control
#--------------------

#--------------------
# Language & Region
#--------------------

# 日付の書式設定等は変更のたびに下部の表示例を動的に変えているっぽい

#--------------------
# Security & Privacy
#--------------------

# May not be configurable by defaults command

#--------------------
# Spotlight
#--------------------

# TODO: excluding

#--------------------
# Notification
#--------------------

#--------------------
# Displays
#--------------------

# Enable HiDPI display modes (requires restart)
# ?
# sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true

# Show mirroring option on menu bar if available
defaults write com.apple.airplay showInMenuBarIfPresent -bool true

#--------------------
# Energy Saver
#--------------------

IS_LAPTOP=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Model Identifier" | grep "Book")
if [[ "$IS_LAPTOP" != "" ]]; then
  sudo pmset -b displaysleep 5 disksleep 10 sleep 15 lessbright 0 halfdim 1
  sudo pmset -c displaysleep 180 disksleep 0 sleep 0
else
  sudo pmset sleep 0 disksleep 0 displaysleep 180 halfdim 1
fi

#--------------------
# Keyboard
#--------------------

# Increase key repeat
defaults write NSGlobalDomain KeyRepeat -int 1

# Decrease key repeat delay

defaults write NSGlobalDomain InitialKeyRepeat -int 13

# Text settings

# Disable automatic spelling correction
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
defaults write NSGlobalDomain WebAutomaticSpellingCorrectionEnabled -bool false

# Disable automatic capitalization
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false

# Disable automatic period substitution
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false

# Turn off smart quote/dash substitution
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false

# Keyboard shortcut settings

# Switching to the next window
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 27 "<dict><key>enabled</key><true/><key>value</key><dict><key>parameters</key><array><integer>96</integer><integer>50</integer><integer>1048576</integer></array><key>type</key><string>standard</string></dict></dict>"

# input sources
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 60 "<dict><key>enabled</key><false/></dict>"
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 61 "<dict><key>enabled</key><true/><key>value</key><dict><key>parameters</key><array><integer>106</integer><integer>38</integer><integer>1048576</integer></array><key>type</key><string>standard</string></dict></dict>"

# Spotlight
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 64 "<dict><key>enabled</key><false/></dict>"

# IME setting seems to be difficult to configure by defaults command

#defaults write com.apple.HIToolbox AppleEnabledInputSources -array \
#'{ "Bundle ID" = "com.apple.PressAndHold"; InputSourceKind = "Non Keyboard Input Method"; }' \
#'{ "Bundle ID" = "com.google.inputmethod.Japanese"; "Input Mode" = "com.apple.inputmethod.Japanese"; InputSourceKind = "Input Mode"; }' \
#'{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 0; "KeyboardLayout Name" = "U.S."; }' \
#'{ "Bundle ID" = "com.google.inputmethod.Japanese"; InputSourceKind = "Keyboard Input Method"; }'

#defaults write com.apple.HIToolbox AppleInputSourceHistory -array \
#'{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 0; "KeyboardLayout Name" = "U.S."; }' \
#'{ "Bundle ID" = "com.google.inputmethod.Japanese"; "Input Mode" = "com.apple.inputmethod.Japanese"; InputSourceKind = "Input Mode"; }'
{'fraction_non_alphanumeric': 0.171284849518288, 'fraction_numerical': 0.011424673885241708, 'mean_word_length': 3.4600760456273765, 'pattern_counts': {'":': 0, '<': 115, '<?xml version=': 0, '>': 118, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4964888', 'n_tokens_mistral': 3594, 'n_tokens_neox': 3366, 'n_words': 1017}