macOS Tips and Tricks

😎: Tips from the excellent Saurabh Site

System

Native UI Conventions 😎


Mission Control / Window Management 😎


Save Dialogs 😎


Turn Off Default iCloud Save Location

I’m sure I recall a checkbox or option for this but a web search only returns this command: defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false


Function Keys 😎



Dock 😎


Spotlight 😎


Screenshots 😎


Remove Dropshadows from Screenshots

To remove dropshadows from screenshots enter the following command :

defaults write com.apple.screencapture disable-shadow -bool true

You have to log out or restart to see changes. Also bare in mind that you cannot add the shadows back in by using the option key which would have been neat.


Rebuild the ‘Launch Services’ to remove duplicates in the ’Open With…” menu.

Fire this command into the terminal and you’re good to go!

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user


Refresh LaunchPad

defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock


Flush DNS cache

sudo killall -HUP mDNSResponder;
sudo killall mDNSResponderHelper;
sudo dscacheutil -flushcache

Enable text selection in Quicklook

defaults write com.apple.finder QLEnableTextSelection -bool true && killall Finder


Refresh Icon Cache

Should you ever find a need to refresh icons here’s the ticket : sudo find /private/var/folders/ -name com.appple.dock.iconcache -exec rm {} \; sudo find /private/var/folders -name com.apple.iconservices -exec rm -rf {} \; sudo mv /Library/Caches/com.apple.iconservices.store com.apple.ic killAll Dock


View Installed Files from PKG Manifest (BOM)

To view what files were installed via a package you need to have a look in the /var/db/receipts/. This folder holds all the bill of materials files, otherwise known as BOM, left by package installers. Once you’ve found the culprit issue the following command to get a list of installed files :

lsbom -f <BOM FILE>


Fix Attempt for WindowServer

Sometimes the UI lags in macOS. Sucks. It’s difficult to pinpoint the whys and wherefores of this phenomena but a potential solution could be:

killall Dock
killall Finder
killall SystemUIServer

process -a $PROCESS

Don’t run all of these together: try each one in order and check if it fixes the problem. The second part, process -a … is used in the event that the process killed doesn’t come back.


After Safe Boot

Safe Boot( hold down shift while booting ) is useful to refresh the system. System caches are deleted and will be rebuilt. The problem is after booting normally you may find ram usage is rather high. Should you find this enter this command to fix the problem :

sudo update_dyld_shared_cache -force


Disable SIP

Sometimes you may need to make some system modifications and that means disabling SIP. Here’s how :

Reboot the computer and at the chime hold down the following CMD+R+S. This will startup recovery mode in single user-mode. The benefit of using single-user mode is how much faster it is to boot into rather than the full gui version. Once you’re at the prompt write this csrutil disable. Done.


Reset NVRAM

You know the drill. Hit these keys immediately after starting up the computer :

⌃ + ⌘ + P + R

After about 20 seconds, or after two chimes, release and startup as per usual. Change any settings that may have been reset.


Change Hibernate Mode

The default hibernation mode is “safe sleep”. This stores the contents of RAM to file that is restored when the laptop runs out of power. This sounds just swell but if one runs the laptop connected to power and in clamshell mode all the time its a waste of space so let’s change it.

# Use this to determine the current status (default is mode '3')
pmset -g | grep hibernatemode
# Change hibernate mode
sudo pmset -a hibernatemode 0

After doing this you should restart to take effect. Any sleep images in /private/var/vm/ can be deleted if not already.


Font Smoothing Post High Sierra

Font smoothing has taken a turn for the worse on non-retina screens in Mojave and requires some cajoling to get it right.

defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO

Restart or log out to take effect.


Enabling SSD Trim

When doing a clean install one usually has to re-enable trim on the third-party SSD and then restart. By the way, if you need to do a few commands that require restarting then doing them all together! Remember, when running trimforce it will restart automatically so run that command last.

sudo trimforce enable


Fix GOG Installers

Often GOG package installers do not actually install anything. In order to get a working application try the following instructions:

xar -xf $PACKAGE
cd package.pkg
tar -xvf Scripts

Have a look inside the package.pkg file for the payload folder. Drag this folder out to another location and rename $GAME_NAME.app. Test that it runs and then move the application anywhere you see fit. Consider automating to procedure.


Lockscreen Background not Reflecting your Wallpaper?

¿El fondo de lockscreen no se parece al papel de empapelar? Sin problema. Una carpeta necesaria no existe en su sistema. Vamos a arreglar lo. Coge su UUID desde usarios & grupos del preferencias de sistema y navega a /Library/Caches/. Si una capeta nombrada ‘Desktop Pictures’ existe, entra en la o crea la capeta con ese nombre. Dentro, crea otra carpeta con su UUID. Listo.


Incorrect TMPDIR permissions

For whatever the system $TMPDIR pointed to the wrong, unwritable, directory after a system upgrade. The typescript lsp wouldn’t start in neovim due to this error so let’s fix it. Type this commmand: launchctl setenv TMPDIR "$( getconf DARWIN_USER_TEMP_DIR )"

launchctl setenv will set a given variable across the whole system for both cli and gui applications whilst getconf DARWIN… will get the correct user temp directory.

Once you’ve run the command ensure you restart the terminal for the changes to take hold.

Finder

Tips and Tricks 😎


Reset Finder Views

Finder can be a touch pedantic about remembering how it was last displayed. Sometimes you may want to reset all folders to the default view. Use this code to remedy it :

sudo find / -name .DS_Store -delete; killall Finder


Safari

Tips and Tricks 😎


Extensions Vanished?

Run this: /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f -R /Applications/Safari.app


Debug Menu

defaults write com.apple.Safari IncludeInternalDebugMenu 1 - use this command to enable the Safari debug menu. This is useful for many reasons but in particular one can disable autoplaying video. Incidentally, should you wish to use Safari Technology Preview you can use the same command as above but add amend it to read as follows : com.apple.SafariTechnologyPreview.


Permanently Change User Agent in Safari

To find user agent strings you can hover over the options in Developer -> User Agent or search online.

defaults write com.apple.Safari CustomUserAgent "\" user agent string here "\"


nb. This should probably be in the legacy section… Source Essentially, hyperlink auditing (<a ping> attribute) is designed to notify an arbitrary website when you click on a link.

Use these commands in the terminal to disable :

defaults write com.apple.Safari WebkitHyperlinkAuditingEnabled -bool false
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2HyperlinkAuditingEnabled -bool false

Mail 😎

Tips and Tricks


Preview

Tips and Tricks 😎


Calendar

Tips and Tricks 😎


Messages

Tips and Tricks 😎


Photos

Tips and Tricks 😎


TextEdit

Tips and Tricks 😎


Terminal

Tips and Tricks 😎


App Store

Show App Store Debug Menu

defaults write com.apple.appstore ShowDebugMenu -bool true 


Dictionary

Webster’s Unabridged Dictionary for Mac OS X Dictionary app!

Better default dictionary from http://jsomers.net/blog/dictionary.

git clone https://github.com/altosaar/webster-mac.git
cp -r webster-mac/Webster\'s\ Unabridged\ Dictionary.dictionary /Users/`whoami`/Library/Dictionaries/
  1. Clone and copy Webster's Unabridged Dictionary.dictionary to your /Library/Dictionaries folder:
  2. Go to Preferences of Dictionary.app, select Webster’s Unabridged Dictionary and drag it to the top.
  3. Enjoy better defaults.

Legacy

Manually fix ownership of System Files

The command to change ownership back to the system is as follows. Use this when it DOES NOT make sense to do a full repair disk command.

sudo chown -R root:wheel ___file_____


Mavericks AppleRTC patch

Use this command in the terminal (on the file within the MacOS folder) to fix CMOS resets:

sudo perl -pi -e 's|\x75\x2e\x0f\xb6|\xeb\x2e\x0f\xb6|'


Show or Hide hidden Files  

Use ‘killAll Finder’ to refresh. defaults write com.apple.finder AppleShowAllFiles TRUE / FALSE

Update: no need for this anymore, simply hit ⇧⌘.


Enable Airdrop on unsupported models

defaults write com.apple.NetworkBrowser BrowseAllInterfaces 1 killAll Finder


Disabling Photos Photo Scanning

To stop photoanalysisd from running and slowing down Photos immensely, try the following command:

sudo launchctl remove com.apple.photoanalysisd

# To re-enable
sudo launchctl load com.apple.photoanalysisd

You may need to restart or logout to see changes but it seems to survive subsequent restarts/shut downs and OS updates.

Catalina

The above command doesn’t seem to work on Catalina so try this instead: launchctl unload -w /System/Library/LaunchAgents/com.apple.photoanalysisd.plist.


Disable iTunes backup

defaults write com.apple.iTunes DeviceBackupsDisabled -bool YES - What’s the point of backing up your iPhone? It’s not clear at all and it’s a pain so let’s disable that shall we?