OS X
Spotlight
Disabling Spotlight indexing while indexing is in progress
From Spotlight tips
sudo mdutil -i off /path_to_volume
Disabling spotlight on some volume
Create an empty file with name .metadata_never_index
in the volume’s root
folder.
It’s better to also put an empty file named no_log
in .fsevent
.
Command line settings
The following several settings are from Top 15 Terminal Commands for Hidden Settings in Snow Leopard and Terminal Commands for Hidden Settings in Leopard
Reset “Open With” menu
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister \
-kill -r -domain local -domain system -domain user
The open with preference is stored in
~/Library/Preferences/com.apple.LaunchServices.plist
. If resetting does not
work, try first delete that file.
Show hidden files in the Finder
defaults write com.apple.finder AppleShowAllFiles -bool YES
Show full path in Finder’s title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
Disable crash reporter dialog
This does not disable crash logging
defaults write com.apple.CrashReporter DialogType none
Other command line settings
From this gist. The following are what I used.
echo "Enable iTunes track notifications in the Dock"
defaults write com.apple.dock itunes-notifications -bool true
echo "Disable the “Are you sure you want to open this application?” dialog"
defaults write com.apple.LaunchServices LSQuarantine -bool false
echo "Avoid creating .DS_Store files on network volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
echo "Disable the warning before emptying the Trash"
defaults write com.apple.finder WarnOnEmptyTrash -bool false
echo "Make Safari’s search banners default to Contains instead of Starts With"
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
echo "Disable Safari’s thumbnail cache for History and Top Sites"
# To re-enable, invoke the command without "-int 2"
defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
echo "Disable dashboard"
defaults write com.apple.dashboard mcx-disabled -boolean true
Change Calendar/Fanstical default event duration
echo "Change Calendar default event duration"
defaults write com.apple.iCal 'Default duration in minutes for new event' 15
echo "Change Fantastical default event duration time"
defaults write com.flexibits.fantastical 'Default duration in minutes for new event' 0
Use 64 bit kernel
Note, Lion uses 64 bit kernel by default.
During startup, press and hold “6” and “4” keys. To use 64 bit as default kernel, use:
sudo systemsetup -setkernelbootarchitecture x86_64
Press “3” and “2” or change x86_64
to i386
for 32 bit kernel.
Time Machine related
Disable local Time Machine
Local Time Machine backup takes up too much disk space. Use the following command to disable it:
sudo tmutil disablelocal
Manually delete backups
From apple.stackexchange
sudo tmutil delete /Volumes/drive_name/Backups.backupdb/mac_name/YYYY-MM-DD-hhmmss
VNC client shipped in OS X
It’s located at /System/Library/CoreServices/Screen Sharing.app
Disable hibernate
I replaced the optical driver with an SSD disk. Hibernate will create a memory
image file /var/vm/sleepimage
to ensure recover state after running out of
battery. This is rare case for me so I disable it. This can also speed up
sleeping since no data need to be written to disk.
$ sudo pmset -a hibernatemode 0
$ sudo rm /var/vm/sleepimage
More info on OS X Daily. If hibernate is not disabled, after deletion of the sleep image, it will be recreated the next time you put Mac into sleep.
Enable TRIM for SSD
From Grant Pannell, or look at this gist.
Backup
cd /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/ sudo cp IOAHCIBlockStorage IOAHCIBlockStorage.bak
Patch the driver
FOR ML 10.8.3 sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage FOR ML 10.8.1-10.8.2 AND LION 10.7.5 sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x4D)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage FOR ML 10.8.0 AND LION 10.7.4 BELOW sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x51)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
Force a refresh of the system’s kernel extension cache
sudo touch /System/Library/Extensions/
Reboot
VMware Fusion 4 network setting
My wireless route uses 192.168.1.0/24 as the network address range, this conflicts with the NAT address used by VMware Fusion. So I want to change the address used by VMware.
From the document VMware Fusion network setting
What does the 2 virtual network cards do?
- vmnet1: host only network
- vmnet8: NAT network
The following instructions to change NAT address range are learnt from Thomas Vachon
- The configuration is located at
/Library/Preferences/VMware Fusion/networking
. What need to be changed should be obvious - Files that will be automatically updated after staring VMware Fusion
networking
vmnet8/{dhcpd.conf,nat.conf}
Notelocations
will not be updated, but I have no problem even if I don’t update it.
Kernel module utilities
From Mac OS X for Unix Geeks
kextload
kextunload
kextstat
: display status of loaded kernel extensions
Dynamic library related
Look for which dynamic library is needed for a binary:
otool -L foo
From man dyld
, by export DYLD_PRINT_LIBRARIES=anyvalue
, dyld will print out
all the libraries a program is using.
Disable hold key to enter unicode character
defaults write -g ApplePressAndHoldEnabled -bool false
Font smoothing settings
Found on Mac OS X Hints.
Some LCD monitors are detected as CRT and LCD font smoothing is thus disabled.
Prior to Snow Leopard, the font smoothinging options were:
- Automatic – Best for Main Display
- Standard – Best for CRT
- Light
- Medium – Best for Flat Panel
- Strong
In SL, we can only choose Automatic and Standard. To force OS X use LCD font smoothing on all display, use the following command:
defaults -currentHost write -globalDomain AppleFontSmoothing -int 2
The int value can beep – 1, Light – 2, Medium – 3, Strong
Converting DMG to ISO
Use hdiutil
:
hdiutil convert original.dmg -format UDTO -o newisoimage.cdr
OS X insist on naming the ISO file with cdr
extension.
Python: pip install to specified directory
From stackoverflow
pip install --install-option="--prefix=/usr/local" package_name
Adding local dev top level domain
Refer to serverfault.
First create a resolver for dev domain (man 5 resolver
for more info).
# mkdir /etc/resolver
# echo 'nameserver 127.0.0.1' > /etc/resolver/dev
So domains under dev will use name server on 127.0.0.1. So we need to setup a DNS server on local machine. I personally use dnsmasq. Just add the following in dnsmasq’s config:
address=/dev/127.0.0.1
So domains under dev will resolve to 127.0.0.1.
In order to resolve when no network interface is active, create a file /etc/resolver/whatever
nameserver 127.0.0.1
domain .
The name whatever
is used to make it the last match with possible actual domain names.
LaunchDaemons vs. LanuchAgents
From Mac OS X: launch daemons vs launch agents.
LaunchDaemons:
- can run without a user logged in
- can’t display information using GUI
- configuration stored in
- /System/Library/LaunchDaemons (provided by apple)
- /Library/LaunchDaemons (for the rest)
LaunchAgents:
- user need to be logged in to run
- can use GUI
- configuration stored in
- /System/Library/LaunchAgents
- /Library/LaunchAgents
- ~/Library/LaunchAgents
Clean DSN cache
OS X 10.7 & 10.8
sudo killall -HUP mDNSResponder
OS X 10.6
dscacheutil -flushcache