Skip to content

Instantly share code, notes, and snippets.

@MohammedEsafi
Last active February 18, 2024 00:22
Show Gist options
  • Save MohammedEsafi/81953d7901a8ec6c08cfb77d68de6a7a to your computer and use it in GitHub Desktop.
Save MohammedEsafi/81953d7901a8ec6c08cfb77d68de6a7a to your computer and use it in GitHub Desktop.
Just a script I use to reset my computer configuration at 1337 school, as it always gets lost πŸ˜‹
#!/bin/bash
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Restore settings files | script used: https://github.com/MohammedEsafi/FOLDSettings
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
python3 ~/.init/baCkup/drive.py -f restore &> /dev/null
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# General UI/UX
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Enable dark mode and reduce transparency
osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to true'
# Use smooth scrolling
defaults write NSGlobalDomain AppleScrollAnimationEnabled -boolean true
# turn off Wi-Fi Device
networksetup -setairportpower en1 off
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Mouse, keyboard, and input
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Enable key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -boolean false
# Set keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 1
# Set a shorter Delay until key repeat
defaults write NSGlobalDomain InitialKeyRepeat -int 10
# Disable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# iTerm 2
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Don’t display the annoying prompt when quitting iTerm
defaults write com.googlecode.iterm2 PromptOnQuit -bool true
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Screen
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Require password immediately after sleep or screen saver begins
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)
defaults write com.apple.screencapture type -string "jpg"
# Disable shadow in screenshots
defaults write com.apple.screencapture disable-shadow -bool true
# Set the desktop background
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/Users/mesafi/Pictures/BaCkground.jpg"'
# Save screenshots to ~/Pictures/Screenshots
mkdir -p ${HOME}/Pictures/Screenshots 2> /dev/null
defaults write com.apple.screencapture location -string "${HOME}/Pictures/Screenshots"
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Use '$HOME/goinfre/DOWNloads' as Chrome downloads Location
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
mkdir -p ${HOME}/goinfre/DOWNloads 2> /dev/null
defaults write com.google.Chrome NSNavLastRootDirectory -string "/Volumes/Storage/goinfre/$(whoami)/DOWNloads"
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Top bar
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Show keychain status in menu bar.
defaults write com.apple.systemuiserver.plist NSStatusItem\ Visible\ com.apple.menuextra.keychain -bool true
defaults write com.apple.systemuiserver.plist menuExtras -array-add "/Applications/Utilities/Keychain Access.app/Contents/Resources/Keychain.menu"
# Show volume in menu bar
defaults write com.apple.systemuiserver.plist NSStatusItem\ Visible\ com.apple.menuextra.volume -bool true
defaults write com.apple.systemuiserver.plist menuExtras -array-add "/System/Library/CoreServices/Menu Extras/Volume.menu"
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Finder
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Finder: allow quitting via ⌘ + Q; doing so will also hide desktop icons
defaults write com.apple.finder QuitMenuItem -bool true
# Show home folder when opening new windows
defaults write com.apple.finder NewWindowTarget -string "PfHm"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/"
# Disable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -boolean false
# Disable the warning before emptying the Trash
defaults write com.apple.finder WarnOnEmptyTrash -bool false
# Finder: show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Show the ~/Library folder
chflags nohidden ~/Library
# Keep folders on top when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Show items as a list
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
# Disable .DS_Store files on network
defaults write com.apple.desktopservices DSDontWriteNetworkStores -boolean true
# Hiding the files on desktop
defaults write com.apple.finder CreateDesktop -bool false
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Dock
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
defaults write com.apple.dock persistent-apps -array
defaults write com.apple.dock persistent-others -array
# Dock Apps list
List=( "/Applications/Launchpad.app" \
"/Applications/Google Chrome.app" \
"/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" \
"/Applications/Postman.app" \
"/Applications/Slack.app" \
"/Applications/Visual Studio Code.app" \
"/Applications/iTerm.app" \
"/Applications/System Preferences.app" )
for App in "${List[@]}"; do
if [ -d "${App}" ]; then
defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>${App}</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"
fi
done
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Kill affected applications
# ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# force a restart all process with the following command to apply the changes: pkill -u $USER &> /dev/null
# Note that some of these changes require a logout/restart of your OS to take effect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment