Skip to content

Instantly share code, notes, and snippets.

@sideseal
Last active December 21, 2022 06:40
Show Gist options
  • Save sideseal/3c734cef0e9258708d4df29f09dad2b5 to your computer and use it in GitHub Desktop.
Save sideseal/3c734cef0e9258708d4df29f09dad2b5 to your computer and use it in GitHub Desktop.
MacOS System Preferences settings for 42
<!-- If you create 'settings.sh' file, You should make plist file in '~/Library/LaunchAgents' folder.
try 'touch' command:
> `touch ~/Library/LaunchAgents/LoginScripts.plist`
and write the code below in '~/Library/LaunchAgents/LoginScripts.plist' -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<!-- You should write Unique ID. You can write filename as a default. -->
<string>LoginScripts.plist</string>
<key>ProgramArguments</key>
<array>
<!-- Write an absolute path where 'settings.sh' is stored. -->
<string>/Users/<userID>/path/to/settings.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
<key>SHELL</key>
<string>/bin/bash</string>
</dict>
</plist>
<!-- And last, launch the `launchctl` command! This will excute settings.zsh when you login.
> launchctl load ~/Library/LaunchAgents/LoginScripts.plist
-->
#/usr/bin/env bash
pkill -u "${USER}" -f "^/System/Applications/System Preferences.app/Contents/MacOS/System Preferences$" 2>/dev/null
# Keyboard/Delay Until Repeat (Long: 120 <---> Short: 15)
defaults -currentHost write ~/Library/Preferences/ByHost/.GlobalPreferences.plist InitialKeyRepeat -int 15
defaults write ~/Library/Preferences/.GlobalPreferences.plist InitialKeyRepeat -int 15
# Keyboard/Key Repeat (Slow: 120 <---> Fast: 2)
defaults -currentHost write ~/Library/Preferences/ByHost/.GlobalPreferences.plist KeyRepeat -int 2
defaults write ~/Library/Preferences/.GlobalPreferences.plist KeyRepeat -int 2
# Mouse/Tracking speed (Slow: 0 <---> Fast: 3)
defaults -currentHost write ~/Library/Preferences/ByHost/.GlobalPreferences.plist com.apple.mouse.scaling -int 2
defaults write ~/Library/Preferences/.GlobalPreferences.plist com.apple.mouse.scaling -int 2
# Mouse/Scrolling speed (Slow: 0 <---> Fast: 5)
defaults -currentHost write ~/Library/Preferences/ByHost/.GlobalPreferences.plist com.apple.scrollwheel.scaling -int 5
defaults write ~/Library/Preferences/.GlobalPreferences.plist com.apple.scrollwheel.scaling -int 5
# Mouse/Double-Click speed (Slow: 5 <---> Fast: 0.15)
defaults -currentHost write ~/Library/Preferences/ByHost/.GlobalPreferences.plist com.apple.mouse.doubleClickThreshold -float 0.15
defaults write ~/Library/Preferences/.GlobalPreferences.plist com.apple.mouse.doubleClickThreshold -float 0.15
# Mouse/Scroll direction: Natural (Lion-style: true <---> general: false)
defaults -currentHost write ~/Library/Preferences/ByHost/.GlobalPreferences.plist com.apple.swipescrolldirection -bool false
defaults write ~/Library/Preferences/.GlobalPreferences.plist com.apple.swipescrolldirection -bool false
# General/Automatically hide and show the menu bar (Hide: true <---> Reveal: false)
defaults -currentHost write ~/Library/Preferences/ByHost/.GlobalPreferences.plist _HIHideMenuBar -bool true
defaults write ~/Library/Preferences/.GlobalPreferences.plist _HIHideMenuBar -bool true
pkill -u "${USER}" -l "^/usr/sbin/cfprefsd agent$" 2>/dev/null
pkill -u "${USER}" -f "^/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder$" 2>/dev/null
launchctl load ~/Library/LaunchAgents/LoginScripts.plist
launchctl start LoginScripts.plist
# If you want to read the applied settings...
# > defaults -currentHost read ~/Library/Preferences/ByHost/.GlobalPreferences.plist
# ... or want to delete the applied setting...
# > defaults delete ~/Library/Preferences/ByHost/.GlobalPreferences.plist <preferences items>
# for example: delete 'scroll direction' setting:
# > defaults delete ~/Library/Preferences/ByHost/.GlobalPreferences.plist com.apple.swipescrolldirection
# You can find more macOS settings here: https://github.com/kevinSuttle/macOS-Defaults/blob/master/.macos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment