-
-
Save thimslugga/1c3dc52849adf41c9ca4bd1ccd941e6a to your computer and use it in GitHub Desktop.
Mac Startup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# exit when any command fails | |
set -e | |
# keep track of the last executed command | |
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG | |
# echo an error message before exiting | |
trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT | |
# 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' | |
# Ask for the administrator password upfront | |
sudo -v | |
# Keep-alive: update existing `sudo` time stamp until `.macos` has finished | |
while true; do | |
sudo -n true | |
sleep 60 | |
kill -0 "$$" || exit | |
done 2>/dev/null & | |
# Install Homebrew | |
echo | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" | |
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>~/.zprofile | |
eval "$(/opt/homebrew/bin/brew shellenv)" | |
# Shell things | |
brew install \ | |
aria2 \ | |
bat \ | |
broot \ | |
curl \ | |
entr \ | |
exa \ | |
fd \ | |
fish \ | |
fzf \ | |
git \ | |
git-extras \ | |
git-lfs \ | |
less \ | |
mas \ | |
neovim \ | |
reattach-to-user-namespace \ | |
ripgrep \ | |
peco \ | |
ripgrep \ | |
starship \ | |
tealdeer \ | |
thefuck \ | |
tmux \ | |
tree-sitter \ | |
wget \ | |
zoxide | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
git lfs install | |
git lfs install --system | |
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ | |
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' | |
sudo sh -c "echo $(which fish) >> /etc/shells" | |
chsh -s $(which fish) | |
# curl -L https://get.oh-my.fish | fish # FZF collision | |
# fish -c "curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher" | |
# https://github.com/ryanoasis/nerd-fonts | |
brew tap homebrew/cask-fonts | |
brew install font-fira-code-nerd-font | |
# tmux conf https://github.com/gpakosz/.tmux | |
cd | |
git clone https://github.com/gpakosz/.tmux.git | |
ln -s -f .tmux/.tmux.conf | |
# cp .tmux/.tmux.conf.local . | |
brew install \ | |
autoconf \ | |
cmake \ | |
coreutils \ | |
duf \ | |
duti \ | |
gpg \ | |
htop \ | |
mackup \ | |
nvm \ | |
openssl \ | |
pandoc \ | |
pinentry-mac \ | |
tesseract \ | |
youtube-dl \ | |
zstd | |
brew install --cask \ | |
alfred \ | |
amethyst \ | |
coconutbattery \ | |
displaycal \ | |
docker \ | |
firefox \ | |
gitkraken \ | |
google-analytics-opt-out \ | |
google-chrome \ | |
iina \ | |
istat-menus \ | |
karabiner-elements \ | |
microsoft-office \ | |
monitorcontrol \ | |
obsidian \ | |
openinterminal \ | |
signal \ | |
slack \ | |
sublime-text \ | |
teamviewer \ | |
the-unarchiver \ | |
visual-studio-code \ | |
zoom | |
MINIFORGE="Miniforge3-MacOSX-arm64.sh" | |
wget https://github.com/conda-forge/miniforge/releases/latest/download/$MINIFORGE | |
chmod +x $MINIFORGE | |
./$MINIFORGE -b -p $HOME/miniforge3 | |
rm $MINIFORGE | |
bash -e "conda init zsh" | |
source ~/.zshrc | |
conda config --set changeps1 False | |
ln -s /opt/homebrew/bin/python3 /opt/homebrew/bin/python | |
wget https://github.com/chaichontat/vscode-theme-darcula/releases/download/v1.2.3/vscode-theme-darculacs-1.2.3.vsix | |
code --install-extension vscode-theme-darculacs-1.2.3.vsix | |
rm vscode-theme-darculacs-1.2.3.vsix | |
# Quicklook plugins | |
# https://github.com/sindresorhus/quick-look-plugins | |
brew install qlcolorcode qlstephen qlmarkdown quicklook-json qlimagesize suspicious-package apparency quicklookase qlvideo | |
xattr -r ~/Library/QuickLook | |
xattr -d -r com.apple.quarantine ~/Library/QuickLook | |
# Allow text selection in QuickLook | |
defaults write com.apple.finder QLEnableTextSelection -bool true | |
############################################################################### | |
# General UI/UX # | |
############################################################################### | |
# Disable the sound effects on boot | |
sudo nvram SystemAudioVolume=" " | |
# Adjust toolbar title rollover delay | |
defaults write NSGlobalDomain NSToolbarTitleViewRolloverDelay -float 0 | |
# Increase window resize speed for Cocoa applications | |
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001 | |
# Expand save panel by default | |
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true | |
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true | |
# Expand print panel by default | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true | |
# Save to disk (not to iCloud) by default | |
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false | |
# Automatically quit printer app once the print jobs complete | |
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true | |
# Disable the “Are you sure you want to open this application?” dialog | |
defaults write com.apple.LaunchServices LSQuarantine -bool false | |
# Remove duplicates in the “Open With” menu (also see `lscleanup` alias) | |
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user | |
# Disable the crash reporter | |
defaults write com.apple.CrashReporter DialogType -string "none" | |
# Disable automatic capitalization as it’s annoying when typing code | |
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false | |
# Disable smart dashes as they’re annoying when typing code | |
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false | |
# Disable automatic period substitution as it’s annoying when typing code | |
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false | |
# Disable smart quotes as they’re annoying when typing code | |
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false | |
# Disable auto-correct | |
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false | |
defaults write NSGlobalDomain NSAutomaticTextCompletionEnabled -bool false | |
defaults write com.apple.controlcenter "NSStatusItem Visible Sound" -bool true | |
defaults write com.apple.controlcenter "NSStatusItem Visible WiFi" -bool true | |
defaults write com.apple.controlcenter "NSStatusItem Visible Bluetooth" -bool true | |
defaults write com.apple.Accessibility ReduceMotionEnabled -bool true | |
############################################################################### | |
# Trackpad, mouse, keyboard, Bluetooth accessories, and input # | |
############################################################################### | |
# Disable press-and-hold for keys in favor of key repeat | |
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false | |
# Set a blazingly fast keyboard repeat rate | |
defaults write NSGlobalDomain KeyRepeat -int 2 | |
defaults write NSGlobalDomain InitialKeyRepeat -int 25 | |
# Show language menu in the top right corner of the boot screen | |
sudo defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool true | |
# Stop iTunes from responding to the keyboard media keys | |
launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist 2>/dev/null | |
# enable app store and identified developers | |
sudo spctl --master-enable | |
sudo spctl --enable | |
# turn on firewall | |
sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 1 | |
# allow integrated signed and downloaded apps | |
sudo defaults write /Library/Preferences/com.apple.alf allowsignedenabled -int 1 | |
sudo defaults write /Library/Preferences/com.apple.alf allowdownloadsignedenabled -int 1 | |
# no ad tracking | |
defaults write com.apple.AdLib.plist forceLimitAdTracking -bool true | |
# reopen all windows after next login | |
# false = disable, true = enable | |
defaults write com.apple.loginwindow TALLogoutSavesState -bool false | |
############################################################################### | |
# Finder # | |
############################################################################### | |
# Set Home as the default location for new Finder windows | |
# For other paths, use `PfLo` and `file:///full/path/here/` | |
defaults write com.apple.finder NewWindowTarget -string "PfHm" | |
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/" | |
# Finder: show all filename extensions | |
defaults write NSGlobalDomain AppleShowAllExtensions -bool true | |
# warning before deleting from icloud drive | |
defaults write com.apple.finder FXEnableRemoveFromICloudDriveWarning -bool false | |
# When performing a search, search the current folder by default | |
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" | |
# Disable the warning when changing a file extension | |
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false | |
# Enable spring loading for directories | |
defaults write NSGlobalDomain com.apple.springing.enabled -bool true | |
# Remove the spring loading delay for directories | |
defaults write NSGlobalDomain com.apple.springing.delay -float 0.3 | |
# Avoid creating .DS_Store files on network or USB volumes | |
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true | |
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true | |
# Disable disk image verification | |
defaults write com.apple.frameworks.diskimages skip-verify -bool true | |
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true | |
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true | |
# 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 | |
# Enable snap-to-grid for icons on the desktop and in other icon views | |
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist | |
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist | |
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist | |
# Set text size | |
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:textSize 12" ~/Library/Preferences/com.apple.finder.plist | |
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:textSize 12" ~/Library/Preferences/com.apple.finder.plist | |
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:textSize 12" ~/Library/Preferences/com.apple.finder.plist | |
# Use list view in all Finder windows by default | |
# Four-letter codes for the other view modes: `icnv`, `clmv`, `glyv` | |
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv" | |
defaults write com.apple.finder FXPreferredSearchViewStyle -string "Nlsv" | |
# Disable the warning before emptying the Trash | |
defaults write com.apple.finder WarnOnEmptyTrash -bool false | |
# Show the ~/Library folder | |
chflags nohidden ~/Library && xattr -d com.apple.FinderInfo ~/Library | |
# Show the /Volumes folder | |
sudo chflags nohidden /Volumes | |
# Expand the following File Info panes: | |
# “General”, “Open with”, and “Sharing & Permissions” | |
defaults write com.apple.finder FXInfoPanesExpanded -dict \ | |
General -bool true \ | |
OpenWith -bool true \ | |
Privileges -bool true | |
############################################################################### | |
# Dock, Dashboard, and hot corners # | |
############################################################################### | |
# Wipe all (default) app icons from the Dock | |
# This is only really useful when setting up a new Mac, or if you don’t use | |
# the Dock to launch apps. | |
#defaults write com.apple.dock persistent-apps -array | |
# Show only open applications in the Dock | |
#defaults write com.apple.dock static-only -bool true | |
# Speed up Mission Control animations | |
defaults write com.apple.dock expose-animation-duration -float 0.1 | |
# Don’t group windows by application in Mission Control | |
# (i.e. use the old Exposé behavior instead) | |
defaults write com.apple.dock expose-group-by-app -bool false | |
# Disable Dashboard | |
defaults write com.apple.dashboard mcx-disabled -bool true | |
# Don’t show Dashboard as a Space | |
defaults write com.apple.dock dashboard-in-overlay -bool true | |
# Don’t automatically rearrange Spaces based on most recent use | |
defaults write com.apple.dock mru-spaces -bool false | |
# 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.1 | |
# Automatically hide and show the Dock | |
defaults write com.apple.dock autohide -bool true | |
# Don’t show recent applications in Dock | |
defaults write com.apple.dock show-recents -bool false | |
# Set Dock icon size | |
defaults write com.apple.dock tilesize -int 60 | |
# Enable spring loading for all Dock items | |
defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true | |
# Hot corners | |
# 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 | |
# 13: Lock Screen | |
# Top left screen corner → Mission Control | |
# defaults write com.apple.dock wvous-tl-corner -int 2 | |
# defaults write com.apple.dock wvous-tl-modifier -int 0 | |
# Top right screen corner → Desktop | |
defaults write com.apple.dock wvous-tr-corner -int 12 | |
defaults write com.apple.dock wvous-tr-modifier -int 0 | |
# Bottom left screen corner → Start screen saver | |
# defaults write com.apple.dock wvous-bl-corner -int 5 | |
# defaults write com.apple.dock wvous-bl-modifier -int 0 | |
############################################################################### | |
# Safari & WebKit # | |
############################################################################### | |
# Press Tab to highlight each item on a web page | |
defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true | |
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true | |
# Set Safari’s home page to `about:blank` for faster loading | |
defaults write com.apple.Safari HomePage -string "about:blank" | |
# Allow hitting the Backspace key to go to the previous page in history | |
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true | |
# Hide Safari’s bookmarks bar by default | |
defaults write com.apple.Safari ShowFavoritesBar -bool false | |
# Enable Safari’s debug menu | |
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true | |
# Make Safari’s search banners default to Contains instead of Starts With | |
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false | |
# Enable the Develop menu and the Web Inspector in Safari | |
defaults write com.apple.Safari IncludeDevelopMenu -bool true | |
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true | |
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true | |
# Add a context menu item for showing the Web Inspector in web views | |
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true | |
# Enable continuous spellchecking | |
defaults write com.apple.Safari WebContinuousSpellCheckingEnabled -bool true | |
# Disable auto-correct | |
defaults write com.apple.Safari WebAutomaticSpellingCorrectionEnabled -bool false | |
# Disable AutoFill | |
defaults write com.apple.Safari AutoFillPasswords -bool false | |
defaults write com.apple.Safari AutoFillCreditCardData -bool false | |
defaults write com.apple.Safari AutoFillMiscellaneousForms -bool false | |
# Disable auto-playing video | |
defaults write com.apple.Safari WebKitMediaPlaybackAllowsInline -bool false | |
defaults write com.apple.SafariTechnologyPreview WebKitMediaPlaybackAllowsInline -bool false | |
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2AllowsInlineMediaPlayback -bool false | |
defaults write com.apple.SafariTechnologyPreview com.apple.Safari.ContentPageGroupIdentifier.WebKit2AllowsInlineMediaPlayback -bool false | |
# Enable “Do Not Track” | |
defaults write com.apple.Safari SendDoNotTrackHTTPHeader -bool true | |
# Update extensions automatically | |
defaults write com.apple.Safari InstallExtensionUpdatesAutomatically -bool true | |
defaults write com.apple.safari WebKitStorageBlockingPolicy -int 1 | |
defaults write com.apple.safari ShowFavoritesBar-v2 -bool false | |
defaults write com.apple.safari ShowSidebarInNewWindows -bool true | |
# new windows open with: empty page | |
defaults write com.apple.Safari NewWindowBehavior -int 1 | |
defaults write com.apple.Safari NewTabBehavior -int 1 | |
# days of keeping history | |
defaults write com.apple.Safari HistoryAgeInDaysLimit -int 30 | |
defaults write com.apple.safari NSUserKeyEquivalents -dict-add "Stop" -string "@q" | |
defaults write com.apple.preview NSUserKeyEquivalents -dict-add "Highlight Text" -string "@h" | |
defaults write com.readdle.PDFExpert-Mac NSUserKeyEquivalents -dict-add "Day" -string "@\$d" | |
defaults write com.readdle.PDFExpert-Mac NSUserKeyEquivalents -dict-add "Night" -string "@\$n" | |
defaults write com.readdle.PDFExpert-Mac NSUserKeyEquivalents -dict-add "No Left Panel" -string "@~1" | |
############################################################################### | |
# Mail # | |
############################################################################### | |
# Disable send and reply animations in Mail.app | |
defaults write com.apple.mail DisableReplyAnimations -bool true | |
defaults write com.apple.mail DisableSendAnimations -bool true | |
# Copy email addresses as `[email protected]` instead of `Foo Bar <[email protected]>` in Mail.app | |
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false | |
# Display emails in threaded mode, sorted by date (oldest at the top) | |
defaults write com.apple.mail DraftsViewerAttributes -dict-add "DisplayInThreadedMode" -string "yes" | |
defaults write com.apple.mail DraftsViewerAttributes -dict-add "SortedDescending" -string "yes" | |
defaults write com.apple.mail DraftsViewerAttributes -dict-add "SortOrder" -string "received-date" | |
defaults write com.apple.mail NSUserKeyEquivalents -dict-add "Mailbox Search" -string "@\$f" | |
############################################################################### | |
# Activity Monitor # | |
############################################################################### | |
# Show the main window when launching Activity Monitor | |
defaults write com.apple.ActivityMonitor OpenMainWindow -bool true | |
# Visualize CPU usage in the Activity Monitor Dock icon | |
defaults write com.apple.ActivityMonitor IconType -int 5 | |
# Show all processes in Activity Monitor | |
defaults write com.apple.ActivityMonitor ShowCategory -int 0 | |
# Sort Activity Monitor results by CPU usage | |
defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage" | |
defaults write com.apple.ActivityMonitor SortDirection -int 0 | |
############################################################################### | |
# Address Book, Dashboard, iCal, TextEdit, and Disk Utility # | |
############################################################################### | |
# Use plain text mode for new TextEdit documents | |
defaults write com.apple.TextEdit RichText -int 0 | |
# Open and save files as UTF-8 in TextEdit | |
defaults write com.apple.TextEdit PlainTextEncoding -int 4 | |
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4 | |
############################################################################### | |
# Mac App Store # | |
############################################################################### | |
# Enable the automatic update check | |
defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true | |
# Check for software updates daily, not just once per week | |
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1 | |
# Download newly available updates in background | |
defaults write com.apple.SoftwareUpdate AutomaticDownload -int 1 | |
# Install System data files & security updates | |
defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 1 | |
# Automatically download apps purchased on other Macs | |
defaults write com.apple.SoftwareUpdate ConfigDataInstall -int 0 | |
# Turn on app auto-update | |
defaults write com.apple.commerce AutoUpdate -bool true | |
############################################################################### | |
# Photos # | |
############################################################################### | |
# Prevent Photos from opening automatically when devices are plugged in | |
defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true | |
# Use the system-native print preview dialog | |
defaults write com.google.Chrome DisablePrintPreview -bool true | |
defaults write com.google.Chrome.canary DisablePrintPreview -bool true | |
# Expand the print dialog by default | |
defaults write com.google.Chrome PMPrintingExpandedStateForPrint2 -bool true | |
defaults write com.google.Chrome.canary PMPrintingExpandedStateForPrint2 -bool true | |
sudo rm -rf /Applications/GarageBand.app /Applications/iMovie.app | |
# LINE, Vimari, Magnet | |
# AdGuard Safari, Yubico, Tab Suspender, Dark Reader | |
mas install \ | |
539883307 \ | |
1480933944 \ | |
441258766 \ | |
1440147259 \ | |
1497506650 \ | |
1495356253 \ | |
1438243180 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment