Helpful Mac CLI Settings
Mac tries to be the os where everything just works, but there are actually a lot of really powerful and useful settings that do not appear anywhere in the UI. This is a growing list of the hidden options that I use.
Show hidden files
Open finder to a folder
Press Command + Shift + . (period key)
Avoid creating .DS_Store files on network or usb drives
If a Windows machine access a shared storage device, you have probably ran across these extra files in every folder from a Mac that just opens the directory.
defaults write com.apple.desktopservies DSDontWriteNetworkStores -bool true defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
Disable Spotlight
Spotlight is a nice tool when it works, but if you catch your machine CPU and fans maxing out, there is a good chance it is from mdsync.
sudo mdutil -a -i off
mdutil -s #Print indexing status
Or, if you have a drive/folder you want spotlight to ignore, add the file .metadata_never_index
Screenshot Format
While PNGs are lossless and nice, they often are 5x as large as their JPG conterparts
defaults write com.apple.screencapture "type" -string "jpg"
defaults write com.apple.screencapture "type" -string "png"
Hide Desktop Icons
If you have a messy desktop but want to illusion of order when you share your screen, turn off your desktop icons. (the files are all still accessible)
defaults write com.apple.finder "CreateDesktop" -bool "false" && killall Finder
Restart without entering filevault password
Sometimes you need to do a remote restart of a system, and you don’t want it stuck at the power on password screen, this allows you to reboot and fully startup.
sudo fdesetup authrestart
Use your Fingerprint for sudo password
On Sonoma or later you can do this with a single command:
sed "s/^#auth/auth/" /etc/pam.d/sudo_local.template | sudo tee /etc/pam.d/sudo_local
Tired of typing your password anytime you sudo a command, this lets you use your fingerprint instead.
sudo chmod +w /etc/pam.d/sudo
sudo vi /etc/pam.d/sudo
# add the next line after 'auth include sudo_local'
# auth sufficient pam_tid.so
sudo chmod -w /etc/pam.d/sudo