awesome-osx-command-line/README.md

1583 lines
37 KiB
Markdown
Raw Normal View History

2015-09-23 19:18:55 -04:00
<img src="https://cdn.rawgit.com/herrbischoff/awesome-osx-command-line/master/assets/logo.svg" width="600">
2015-09-22 17:23:45 -04:00
> A curated list of shell commands and tools specific to OS X.
2015-09-22 17:48:14 -04:00
>
2015-09-24 12:11:34 -04:00
> _“You dont have to know everything. You simply need to know where to find it when necessary.” (John Brunner)_
2015-09-22 17:23:45 -04:00
2015-10-18 18:56:29 -04:00
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/herrbischoff/awesome-osx-command-line)
2015-09-22 17:28:21 -04:00
2015-09-23 19:20:43 -04:00
If you want to contribute, you are highly encouraged to do so. Please read the [contribution guidelines](contributing.md).
2015-09-22 17:23:45 -04:00
2015-11-07 14:33:29 -05:00
For more terminal shell goodness, please also see this list's sister list [Awesome Command Line Apps](https://github.com/herrbischoff/awesome-command-line-apps).
2015-09-22 17:23:45 -04:00
## Table of Contents
2015-09-24 12:11:34 -04:00
- [Appearance](#appearance)
- [Transparency](#transparency)
- [Wallpaper](#wallpaper)
- [Applications](#applications)
- [App Store](#app-store)
- [Apple Remote Desktop](#apple-remote-desktop)
2016-01-13 21:51:46 -05:00
- [Contacts](#contacts)
- [iTunes](#itunes)
2015-11-14 10:03:40 -05:00
- [Mail](#mail)
2015-10-18 11:45:35 -04:00
- [Safari](#safari)
2015-09-24 12:11:34 -04:00
- [Sketch](#sketch)
2016-02-13 18:46:49 -05:00
- [Skim](#skim)
2015-10-18 11:31:47 -04:00
- [TextEdit](#textedit)
- [Backup](#backup)
- [Time Machine](#time-machine)
2015-09-24 12:11:34 -04:00
- [Developer](#developer)
- [App Icons](#app-icons)
2015-10-17 16:45:00 -04:00
- [Vim](#vim)
2015-09-24 12:11:34 -04:00
- [Xcode](#xcode)
- [Disks and Volumes](#disks-and-volumes)
- [Disk Images](#disk-images)
2015-10-24 17:31:53 -04:00
- [Dock](#dock)
- [Documents](#documents)
2015-09-24 12:11:34 -04:00
- [Finder](#finder)
2015-10-14 19:54:13 -04:00
- [Files and Folders](#files-and-folders)
- [Layout](#layout)
- [Metadata Files](#metadata-files)
2015-10-16 12:56:46 -04:00
- [Opening Things](#opening-things)
2015-09-24 12:11:34 -04:00
- [Fonts](#fonts)
2015-12-03 18:21:31 -05:00
- [Functions](#functions)
2015-09-24 12:11:34 -04:00
- [Hardware](#hardware)
2015-12-30 16:45:48 -05:00
- [Bluetooth](#bluetooth)
2015-09-24 12:11:34 -04:00
- [Hardware Information](#hardware-information)
- [Infrared Receiver](#infrared-receiver)
2015-10-02 16:23:24 -04:00
- [Power Management](#power-management)
2015-09-24 12:11:34 -04:00
- [Input Devices](#input-devices)
- [Keyboard](#keyboard)
- [Media](#media)
- [Audio](#audio)
2015-10-18 13:07:05 -04:00
- [Video](#video)
2015-09-24 12:11:34 -04:00
- [Networking](#networking)
- [Bonjour](#bonjour)
- [DHCP](#dhcp)
- [DNS](#dns)
2015-10-02 19:15:18 -04:00
- [Hostname](#hostname)
- [Network Preferences](#network-preferences)
2015-09-24 12:11:34 -04:00
- [Networking Tools](#networking-tools)
2016-05-08 12:39:25 -04:00
- [SSH](#ssh)
2015-10-13 17:47:14 -04:00
- [TCP/IP](#tcpip)
2015-09-24 12:11:34 -04:00
- [Wi-Fi](#wi-fi)
- [Package Managers](#package-managers)
- [Printing](#printing)
- [Security](#security)
- [Application Firewall](#application-firewall)
2015-09-24 12:11:34 -04:00
- [Gatekeeper](#gatekeeper)
2015-09-25 10:17:11 -04:00
- [Passwords](#passwords)
2015-10-14 20:13:52 -04:00
- [Physical Access](#physical-access)
2015-09-24 12:11:34 -04:00
- [Wiping Data](#wiping-data)
- [Search](#search)
2015-10-14 19:46:18 -04:00
- [Find](#find)
- [Locate](#locate)
2015-09-24 12:11:34 -04:00
- [System](#system)
2015-10-18 11:50:45 -04:00
- [AirDrop](#airdrop)
2015-10-13 14:24:24 -04:00
- [AppleScript](#applescript)
2015-09-24 12:11:34 -04:00
- [Basics](#basics)
- [Clipboard](#clipboard)
- [Date and Time](#date-and-time)
2015-09-24 12:11:34 -04:00
- [FileVault](#filevault)
2015-10-16 08:39:17 -04:00
- [Information/Reports](#informationreports)
2015-09-25 10:49:17 -04:00
- [Kernel Extensions](#kernel-extensions)
2015-10-13 17:56:00 -04:00
- [LaunchAgents](#launchagents)
- [LaunchServices](#launchservices)
2015-10-29 12:36:13 -04:00
- [Login Window](#login-window)
2015-09-24 12:11:34 -04:00
- [Memory Management](#memory-management)
- [Notification Center](#notification-center)
2015-10-02 19:09:54 -04:00
- [QuickLook](#quicklook)
- [Remote Apple Events](#remote-apple-events)
2015-09-24 12:11:34 -04:00
- [Root User](#root-user)
- [Safe Mode Boot](#safe-mode-boot)
- [Screenshots](#screenshots)
2015-09-25 10:48:55 -04:00
- [Software Installation](#software-installation)
2015-10-18 13:03:45 -04:00
- [Software Update](#software-update)
2015-10-13 14:20:04 -04:00
- [Spotlight](#spotlight)
- [System Integrity Protection](#system-integrity-protection)
2015-10-14 20:04:21 -04:00
- [Terminal](#terminal)
- [Alternative Terminals](#alternative-terminals)
2015-10-18 16:47:54 -04:00
- [Shells](#shells)
- [Terminal Fonts](#terminal-fonts)
2015-09-24 12:11:34 -04:00
## Appearance
### Transparency
2015-12-03 18:49:38 -05:00
#### Transparency in Menu and Windows
2015-09-24 12:11:34 -04:00
```bash
2015-12-03 18:49:38 -05:00
# Reduce Transparency
2015-09-24 12:11:34 -04:00
defaults write com.apple.universalaccess reduceTransparency -bool true
2015-12-03 18:49:38 -05:00
# Restore Default Transparency
2015-09-24 12:11:34 -04:00
defaults write com.apple.universalaccess reduceTransparency -bool false
```
2015-12-03 18:49:38 -05:00
2015-09-24 12:11:34 -04:00
### Wallpaper
2015-09-25 09:57:47 -04:00
#### Set Wallpaper
2015-09-24 12:11:34 -04:00
```bash
2015-12-03 18:53:38 -05:00
# Up to Mountain Lion
2015-09-24 12:11:34 -04:00
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/path/to/picture.jpg"'
2015-12-03 18:53:38 -05:00
# Since Mavericks
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '/path/to/picture.jpg'" && killall Dock
```
2015-09-24 12:11:34 -04:00
## Applications
### App Store
#### List All Apps Downloaded from App Store
```bash
find /Applications -path '*Contents/_MASReceipt/receipt' -maxdepth 4 -print |\sed 's#.app/Contents/_MASReceipt/receipt#.app#g; s#/Applications/##'
```
2016-01-21 16:29:38 -05:00
#### Show Debug Menu
2016-01-21 15:43:35 -05:00
```bash
# Enable
defaults write com.apple.appstore ShowDebugMenu -bool true
# Disable (Default)
defaults write com.apple.appstore ShowDebugMenu -bool false
```
2015-09-24 12:11:34 -04:00
### Apple Remote Desktop
#### Remove Apple Remote Desktop Settings
```bash
sudo rm -rf /var/db/RemoteManagement ; \
sudo defaults delete /Library/Preferences/com.apple.RemoteDesktop.plist ; \
defaults delete ~/Library/Preferences/com.apple.RemoteDesktop.plist ; \
sudo rm -r /Library/Application\ Support/Apple/Remote\ Desktop/ ; \
rm -r ~/Library/Application\ Support/Remote\ Desktop/ ; \
2015-09-24 12:11:34 -04:00
rm -r ~/Library/Containers/com.apple.RemoteDesktop
```
2015-09-22 17:23:45 -04:00
2016-01-13 21:51:46 -05:00
### Contacts
#### Debug Mode
```bash
# Enable
defaults write com.apple.addressbook ABShowDebugMenu -bool true
# Disable (Default)
defaults write com.apple.addressbook ABShowDebugMenu -bool false
```
### iTunes
2015-12-03 18:56:45 -05:00
#### Keyboard Media Keys
```bash
2015-12-03 19:04:52 -05:00
# Stop Responding to Key Presses
launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist
2015-12-03 18:56:45 -05:00
2015-12-03 19:04:52 -05:00
# Respond to Key Presses (Default)
2015-12-03 18:56:45 -05:00
launchctl load -w /System/Library/LaunchAgents/com.apple.rcd.plist
```
2015-11-14 10:03:40 -05:00
### Mail
2016-01-02 11:12:40 -05:00
#### Show Attachments as Icons
```bash
defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes
```
2015-11-14 10:03:40 -05:00
#### Vacuum Mail Index
2015-11-14 10:05:17 -05:00
The AppleScript code below will quit Mail, vacuum the SQLite index, then re-open Mail. On a large email database that hasn't been optimized for a while, this can provide significant improvements in responsiveness and speed.
2015-11-14 10:03:40 -05:00
```applescript
(*
Speed up Mail.app by vacuuming the Envelope Index
Code from: http://www.hawkwings.net/2007/03/03/scripts-to-automate-the-mailapp-envelope-speed-trick/
Originally by "pmbuko" with modifications by Romulo
Updated by Brett Terpstra 2012
Updated by Mathias Törnblom 2015 to support V3 in El Capitan and still keep backwards compatibility
2015-11-14 10:03:40 -05:00
*)
tell application "Mail" to quit
set os_version to do shell script "sw_vers -productVersion"
set mail_version to "V2"
considering numeric strings
if "10.10" <= os_version then set mail_version to "V3"
end considering
set sizeBefore to do shell script "ls -lnah ~/Library/Mail/" & mail_version & "/MailData | grep -E 'Envelope Index$' | awk {'print $5'}"
do shell script "/usr/bin/sqlite3 ~/Library/Mail/" & mail_version & "/MailData/Envelope\\ Index vacuum"
set sizeAfter to do shell script "ls -lnah ~/Library/Mail/" & mail_version & "/MailData | grep -E 'Envelope Index$' | awk {'print $5'}"
display dialog ("Mail index before: " & sizeBefore & return & "Mail index after: " & sizeAfter & return & return & "Enjoy the new speed!")
tell application "Mail" to activate
```
2015-10-18 11:45:35 -04:00
### Safari
#### Enable Develop Menu and Web Inspector
```bash
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true && \
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 && \
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
```
2015-10-27 03:24:06 -04:00
#### Get Current Page Data
2015-10-29 11:28:04 -04:00
Other options: `get source`, `get text`.
```bash
osascript -e 'tell application "Safari" to get URL of current tab of front window'
```
2015-09-24 12:11:34 -04:00
### Sketch
#### Export Compact SVGs
```bash
defaults write com.bohemiancoding.sketch3 exportCompactSVG -bool yes
```
2015-09-22 17:23:45 -04:00
2016-02-13 18:46:49 -05:00
### Skim
#### Turn Off Auto Reload Dialog
Removes the dialog and defaults to auto reload.
```bash
defaults write -app Skim SKAutoReloadFileUpdate -boolean true
```
2015-10-18 11:31:47 -04:00
### TextEdit
#### Use Plain Text Mode as Default
```bash
defaults write com.apple.TextEdit RichText -int 0
```
2015-10-13 17:32:14 -04:00
## Backup
### Time Machine
#### Change Backup Interval
This changes the interval to 30 minutes. The integer value is the time in seconds.
```bash
sudo defaults write /System/Library/Launch Daemons/com.apple.backupd-auto StartInterval -int 1800
```
2016-01-13 23:32:52 -05:00
#### Local Backups
Whether Time Machine performs local backups while the Time Machine backup volume is not available.
```bash
# Disable
sudo tmutil disablelocal
# Enable (Default)
sudo tmutil enablelocal
```
2015-12-03 19:02:33 -05:00
#### Prevent Time Machine from Prompting to Use New Hard Drives as Backup Volume
2015-09-25 10:30:38 -04:00
```bash
2015-12-03 19:02:33 -05:00
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
2015-09-25 10:30:38 -04:00
```
2015-12-03 19:02:33 -05:00
#### Set Status
2015-09-25 10:30:38 -04:00
```bash
2015-12-03 19:02:33 -05:00
# Disable Local Time Machine Backups
hash tmutil &> /dev/null && sudo tmutil disablelocal
# Enable Local Time Machine Backups (Default)
hash tmutil &> /dev/null && sudo tmutil enablelocal
2015-09-25 10:30:38 -04:00
```
2015-09-25 10:32:40 -04:00
## Developer
### Vim
#### Compile Sane Vim
2015-10-13 17:39:49 -04:00
Compiling MacVim via Homebrew with all bells and whistles, including overriding system Vim.
```bash
2015-10-15 03:50:20 -04:00
brew install macvim --HEAD --with-cscope --with-lua --with-override-system-vim --with-luajit --with-python
```
2015-12-03 19:09:50 -05:00
#### Neovim
2015-10-18 14:00:49 -04:00
Install the development version of this modern Vim drop-in alternative via Homebrew.
```bash
brew tap neovim/neovim && \
brew install --HEAD neovim
```
### Xcode
#### Install Command Line Tools without Xcode
```bash
xcode-select --install
```
2015-10-15 10:14:11 -04:00
#### Remove All Unavailable Simulators
```bash
xcrun simctl delete unavailable
```
2015-10-17 21:04:03 -04:00
2015-09-24 12:11:34 -04:00
## Disks and Volumes
2015-09-22 17:23:45 -04:00
2015-09-24 12:11:34 -04:00
#### Disable Sudden Motion Sensor
Leaving this turned on is useless when you're using SSDs.
```bash
sudo pmset -a sms 0
```
#### Eject All Mountable Volumes
The only reliable way to do this is by sending an AppleScript command to Finder.
```bash
osascript -e 'tell application "Finder" to eject (every disk whose ejectable is true)'
```
#### Repair File Permissions
You don't have to use the Disk Utility GUI for this.
2015-10-13 14:02:56 -04:00
```bash
sudo diskutil repairPermissions /
2015-10-13 14:02:56 -04:00
```
> Beginning with OS X El Capitan, system file permissions are automatically protected. It's no longer necessary to verify or repair permissions with Disk Utility. ([Source](https://support.apple.com/en-us/HT201560))
2015-10-13 14:02:56 -04:00
#### Set Boot Volume
2015-09-25 10:40:55 -04:00
```bash
bless --mount "/path/to/mounted/volume" --setBoot
2015-09-25 10:40:55 -04:00
```
#### Show All Attached Disks and Partitions
2015-09-25 10:43:15 -04:00
```bash
diskutil list
2015-09-25 10:43:15 -04:00
```
2015-10-19 19:22:46 -04:00
#### View File System Usage
2015-10-31 12:42:43 -04:00
A continuous stream of file system access info.
2015-10-19 19:22:46 -04:00
```bash
sudo fs_usage
```
### Disk Images
2015-11-05 14:26:08 -05:00
#### Create Disk Image From Folder Contents
```bash
hdiutil create -volname "Volume Name" -srcfolder /path/to/folder -ov diskimage.dmg
```
If you'd like to encrypt the disk image:
```bash
hdiutil create -encryption -stdinpass -volname "Volume Name" -srcfolder /path/to/folder -ov encrypted.dmg
```
By default, you'll be prompted for a password. You can automate that by piping in a password:
```bash
echo -n YourPassword | hdiutil create -encryption -stdinpass -volname "Volume Name" -srcfolder /path/to/folder -ov encrypted.dmg
```
2015-11-02 01:16:55 -05:00
#### Burn Disk Images to DVD
This command applies to .iso, .img and .dmg images.
```bash
hdiutil burn /path/to/image_file
```
#### Disable Disk Image Verification
2015-09-22 17:23:45 -04:00
```bash
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
2015-09-22 17:23:45 -04:00
```
#### Make Volume OS X Bootable
2015-10-13 14:02:56 -04:00
```bash
bless --folder "/path/to/mounted/volume/System/Library/CoreServices" --bootinfo --bootefi
2015-10-13 14:02:56 -04:00
```
#### Mount Disk Image
2015-09-25 10:38:10 -04:00
```bash
hdiutil attach /path/to/diskimage.dmg
```
#### Unmount Disk Image
```bash
hdiutil detach /dev/disk2s1
2015-09-25 10:38:10 -04:00
```
2015-10-19 19:16:31 -04:00
#### Write Disk Image to Volume
Like the Disk Utility "Restore" function.
```bash
sudo asr -restore -noverify -source /path/to/diskimage.dmg -target /Volumes/VolumeToRestoreTo
```
2015-09-23 16:28:51 -04:00
2015-10-24 17:31:53 -04:00
## Dock
2015-10-24 17:32:25 -04:00
#### Add a Stack with Recent Applications
2015-10-24 17:31:53 -04:00
```bash
defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }' && \
killall Dock
```
2015-10-27 00:11:13 -04:00
#### Add a Space
2015-10-26 23:45:06 -04:00
```bash
2015-12-03 19:42:12 -05:00
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}' && \
2015-10-27 00:11:13 -04:00
killall Dock
2015-10-26 23:45:06 -04:00
```
2016-03-07 08:09:44 -05:00
#### Icon Bounce
Global setting whether Dock icons should bounce when the respective application demands your attention.
```bash
# Enable (Default)
defaults write com.apple.dock no-bouncing -bool true && \
killall Dock
# Disable
defaults write com.apple.dock no-bouncing -bool false && \
killall Dock
```
2016-03-07 08:29:50 -05:00
#### Reset Dock
2016-03-07 08:21:47 -05:00
```bash
defaults delete com.apple.dock && \
killall Dock
```
2016-03-07 08:27:52 -05:00
#### Scroll Gestures
Use your touchpad or mouse scroll wheel to interact with Dock items. Allows you to use an upward scrolling gesture to open stacks. Using the same gesture on applications that are running invokes Exposé/Mission Control.
```bash
# Enable
defaults write com.apple.dock scroll-to-open -bool true && \
killall Dock
# Disable (Default)
defaults write com.apple.dock scroll-to-open -bool false && \
killall Dock
```
2015-11-04 07:01:23 -05:00
#### Set Auto Show/Hide Delay
The float number defines the show/hide delay in ms.
```bash
2015-12-03 19:42:12 -05:00
defaults write com.apple.Dock autohide-delay -float 0 && \
2015-11-04 07:01:23 -05:00
killall Dock
```
2015-12-03 17:25:24 -05:00
#### Show Hidden App Icons
2015-11-30 07:53:28 -05:00
```bash
2015-12-03 17:25:24 -05:00
# Enable
defaults write com.apple.dock showhidden -bool true && \
killall Dock
# Disable
defaults write com.apple.dock showhidden -bool false && \
2015-11-30 07:53:28 -05:00
killall Dock
```
2015-10-24 17:31:53 -04:00
## Documents
#### Convert File to HTML
Supported formats are plain text, rich text (rtf) and Microsoft Word (doc/docx).
```bash
textutil -convert html file.ext
```
2015-10-14 19:46:18 -04:00
2015-09-22 17:23:45 -04:00
## Finder
2015-10-14 19:54:13 -04:00
### Files and Folders
2015-10-14 19:50:32 -04:00
2015-10-24 17:58:22 -04:00
#### Clear All ACLs
```bash
sudo chmod -RN /path/to/folder
```
2015-10-14 19:51:07 -04:00
#### Hide Folder in Finder
2015-09-22 17:23:45 -04:00
```bash
2015-09-24 12:11:34 -04:00
chflags hidden /path/to/folder/
2015-09-22 17:23:45 -04:00
```
#### Show All File Extensions
```bash
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
```
2015-09-22 17:23:45 -04:00
2015-12-03 19:20:38 -05:00
#### Show Hidden Files
2015-09-24 12:11:34 -04:00
```bash
2015-12-03 19:20:38 -05:00
# Show All
2015-09-24 12:11:34 -04:00
defaults write com.apple.finder AppleShowAllFiles true
2015-12-03 19:20:38 -05:00
# Restore Default File Visibility
2015-09-24 12:11:34 -04:00
defaults write com.apple.finder AppleShowAllFiles false
```
2015-09-22 17:23:45 -04:00
2015-10-24 17:56:41 -04:00
#### Remove Protected Flag
2015-10-24 17:55:52 -04:00
```bash
sudo chflags -R nouchg /path/to/file/or/folder
```
2015-10-18 11:19:25 -04:00
#### Show Full Path in Finder Title
2015-09-24 12:11:34 -04:00
```bash
2015-10-18 11:19:25 -04:00
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
2015-09-24 12:11:34 -04:00
```
2015-09-22 17:23:45 -04:00
2015-10-18 16:15:38 -04:00
#### Unhide User Library Folder
2015-09-22 17:23:45 -04:00
```bash
2015-09-24 12:11:34 -04:00
chflags nohidden ~/Library
2015-09-22 17:23:45 -04:00
```
#### Increase Number of Recent Places
```bash
defaults write .GlobalPreferences NSNavRecentPlacesLimit -int 10 && \
killall Finder
```
### Layout
2015-10-14 19:54:13 -04:00
2016-01-21 18:43:25 -05:00
#### Show "Quit Finder" Menu Item
Makes possible to see Finder menu item "Quit Finder" with default shortcut <kbd>Cmd</kbd> + <kbd>Q</kbd>
```bash
# Enable
2016-04-13 19:09:38 -04:00
defaults write com.apple.finder QuitMenuItem -bool true && \
2016-01-21 18:43:25 -05:00
killall Finder
# Disable (Default)
defaults write com.apple.finder QuitMenuItem -bool false && \
killall Finder
```
2015-12-03 19:20:38 -05:00
#### Smooth Scrolling
2015-10-17 13:13:16 -04:00
Useful if youre on an older Mac that messes up the animation.
```bash
2015-12-03 19:20:38 -05:00
# Disable
2015-10-17 13:13:16 -04:00
defaults write NSGlobalDomain NSScrollAnimationEnabled -bool false
2015-12-03 19:20:38 -05:00
# Enable (Default)
2015-10-17 13:13:16 -04:00
defaults write NSGlobalDomain NSScrollAnimationEnabled -bool true
```
2015-12-03 19:20:38 -05:00
#### Rubberband Scrolling
2015-10-18 17:44:51 -04:00
```bash
2015-12-03 19:20:38 -05:00
# Disable
2015-10-18 17:44:51 -04:00
defaults write -g NSScrollViewRubberbanding -bool false
2015-12-03 19:20:38 -05:00
# Enable (Default)
2015-10-18 17:44:51 -04:00
defaults write -g NSScrollViewRubberbanding -bool true
```
2015-10-17 13:16:00 -04:00
#### Expand Save Panel by Default
```bash
2015-10-18 16:09:58 -04:00
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true && \
2015-10-17 13:16:00 -04:00
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
```
2015-12-03 19:20:38 -05:00
#### Desktop Icon Visibility
2015-10-14 19:54:13 -04:00
```bash
2015-12-03 19:20:38 -05:00
# Hide Icons
defaults write com.apple.finder CreateDesktop -bool false && \
killall Finder
2015-10-14 19:54:13 -04:00
2015-12-03 19:20:38 -05:00
# Show Icons (Default)
defaults write com.apple.finder CreateDesktop -bool true && \
killall Finder
2015-10-14 19:54:13 -04:00
```
2015-12-03 19:20:38 -05:00
#### Path Bar
2015-10-18 13:32:06 -04:00
```bash
2015-12-03 19:20:38 -05:00
# Show
2015-10-18 13:32:06 -04:00
defaults write com.apple.finder ShowPathbar -bool true
2015-12-03 19:20:38 -05:00
# Hide (Default)
defaults write com.apple.finder ShowPathbar -bool false
2015-10-18 13:32:06 -04:00
```
#### Scrollbar Visibility
Possible values: `WhenScrolling`, `Automatic` and `Always`.
```bash
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
```
2015-12-03 19:20:38 -05:00
#### Status Bar
2015-10-18 13:33:29 -04:00
```bash
2015-12-03 19:20:38 -05:00
# Show
2015-10-18 13:33:29 -04:00
defaults write com.apple.finder ShowStatusBar -bool true
2015-12-03 19:20:38 -05:00
# Hide (Default)
defaults write com.apple.finder ShowStatusBar -bool false
2015-10-18 13:33:29 -04:00
```
2015-10-17 13:18:58 -04:00
#### Save to Disk by Default
Sets default save target to be a local disk, not iCloud.
```bash
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
```
2015-10-18 16:15:38 -04:00
#### Set Current Folder as Default Search Scope
```bash
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
```
#### Set Default Finder Location to Home Folder
```bash
defaults write com.apple.finder NewWindowTarget -string "PfLo" && \
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}"
```
2015-10-17 13:04:39 -04:00
#### Set Sidebar Icon Size
Sets size to 'medium'.
```bash
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 2
```
2015-12-03 19:20:38 -05:00
### Metadata Files
#### Disable Creation of Metadata Files on Network Volumes
2015-10-18 16:12:25 -04:00
Avoids creation of `.DS_Store` and AppleDouble files.
```bash
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
```
#### Disable Creation of Metadata Files on USB Volumes
2015-10-18 16:12:25 -04:00
Avoids creation of `.DS_Store` and AppleDouble files.
```bash
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
```
2015-10-17 13:04:39 -04:00
2015-10-16 12:56:46 -04:00
### Opening Things
2015-10-16 08:47:07 -04:00
#### Change Working Directory to Finder Path
If multiple windows are open, it chooses the top-most one.
```bash
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
```
2015-10-16 13:00:44 -04:00
#### Open URL
2015-10-16 08:47:07 -04:00
```bash
2016-02-29 05:51:18 -05:00
open https://github.com
2015-10-16 08:47:07 -04:00
```
2015-10-16 09:00:32 -04:00
#### Open File
2015-10-16 08:47:07 -04:00
```bash
open README.md
```
2015-10-16 09:00:32 -04:00
#### Open Applications
2015-10-16 12:56:46 -04:00
You can open applications using `-a`.
2015-10-16 08:47:07 -04:00
```bash
2016-02-29 05:51:18 -05:00
open -a "Google Chrome" https://github.com
2015-10-16 08:47:07 -04:00
```
2015-10-18 16:15:38 -04:00
#### Open Folder
2015-10-16 08:47:07 -04:00
```bash
2015-10-18 16:15:38 -04:00
open /path/to/folder/
2015-10-16 08:47:07 -04:00
```
2015-10-18 16:15:38 -04:00
#### Open Current Folder
2015-10-16 08:47:07 -04:00
```bash
open .
```
2015-10-16 12:56:46 -04:00
## Fonts
#### Clear Font Cache for Current User
To clear font caches for all users, put `sudo` in front of this command.
```bash
2015-10-18 16:09:58 -04:00
atsutil databases -removeUser && \
atsutil server -shutdown && \
atsutil server -ping
2015-10-16 12:56:46 -04:00
```
2015-12-03 18:21:31 -05:00
## Functions
Please see [this file](functions.md).
2015-09-22 17:23:45 -04:00
## Hardware
2015-12-30 16:45:48 -05:00
### Bluetooth
```bash
# Status
defaults read /Library/Preferences/com.apple.Bluetooth ControllerPowerState
# Enable (Default)
sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 1
# Disable
sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 0 && \
sudo killall -HUP blued
```
2015-09-24 12:11:34 -04:00
### Hardware Information
#### List All Hardware Ports
2015-09-22 17:23:45 -04:00
```bash
networksetup -listallhardwareports
```
#### Remaining Battery Percentage
```bash
pmset -g batt | egrep "([0-9]+\%).*" -o --colour=auto | cut -f1 -d';'
```
#### Remaining Battery Time
```bash
pmset -g batt | egrep "([0-9]+\%).*" -o --colour=auto | cut -f3 -d';'
```
2015-10-19 10:19:40 -04:00
#### Show Connected Device's UDID
```bash
system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p'
```
2015-09-24 12:11:34 -04:00
#### Show Current Screen Resolution
```bash
system_profiler SPDisplaysDataType | grep Resolution
```
2015-10-16 13:55:03 -04:00
#### Show CPU Brand String
```bash
sysctl -n machdep.cpu.brand_string
```
### Infrared Receiver
```bash
# Status
defaults read /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled
# Enable (Default)
defaults write /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled -int 1
# Disable
defaults write /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled -int 0
```
2015-09-24 12:11:34 -04:00
### Power Management
2015-10-02 16:25:34 -04:00
#### Prevent System Sleep
Prevent sleep for 1 hour:
```bash
caffeinate -u -t 3600
```
2015-09-24 12:11:34 -04:00
#### Show All Power Management Settings
2015-09-22 17:23:45 -04:00
```bash
sudo pmset -g
```
#### Put Display to Sleep after 15 Minutes of Inactivity
2015-09-24 12:11:34 -04:00
```bash
sudo pmset displaysleep 15
```
#### Put Computer to Sleep after 30 Minutes of Inactivity
2015-09-24 12:11:34 -04:00
```bash
sudo pmset sleep 30
```
#### Check System Sleep Idle Time
```bash
sudo systemsetup -getcomputersleep
```
#### Set System Sleep Idle Time to 60 Minutes
```bash
sudo systemsetup -setcomputersleep 60
```
#### Turn Off System Sleep Completely
```bash
sudo systemsetup -setcomputersleep Never
```
2015-09-22 17:23:45 -04:00
#### Automatic Restart on System Freeze
```bash
sudo systemsetup -setrestartfreeze on
```
2015-12-03 19:23:12 -05:00
#### Chime When Charging
2015-10-18 16:55:37 -04:00
Play iOS charging sound when MagSafe is connected.
2015-10-18 14:52:42 -04:00
```bash
2015-12-03 19:23:12 -05:00
# Enable
2015-10-18 16:55:37 -04:00
defaults write com.apple.PowerChime ChimeOnAllHardware -bool true && \
open /System/Library/CoreServices/PowerChime.app
2015-10-18 14:52:42 -04:00
2015-12-03 19:23:12 -05:00
# Disable (Default)
2015-10-18 16:55:37 -04:00
defaults write com.apple.PowerChime ChimeOnAllHardware -bool false && \
2015-10-28 17:01:25 -04:00
killall PowerChime
2015-10-18 14:52:42 -04:00
```
2015-10-17 21:04:03 -04:00
2015-12-03 19:23:12 -05:00
## Input Devices
2015-09-24 12:11:34 -04:00
### Keyboard
2015-12-03 19:26:24 -05:00
#### Auto-Correct
```bash
2015-12-03 19:26:24 -05:00
# Disable
2015-09-24 12:11:34 -04:00
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false
2015-12-03 19:26:24 -05:00
# Enable (Default)
2015-09-24 12:11:34 -04:00
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool true
2015-12-03 19:26:24 -05:00
# Show Status
2015-09-24 12:11:34 -04:00
defaults read -g NSAutomaticSpellingCorrectionEnabled
```
2015-12-03 19:26:24 -05:00
#### Key Repeat
2015-10-18 13:28:55 -04:00
Disable the default "press and hold" behavior.
```bash
2015-12-03 19:26:24 -05:00
# Enable Key Repeat
2015-10-18 13:28:55 -04:00
defaults write -g ApplePressAndHoldEnabled -bool false
2015-12-03 19:26:24 -05:00
# Disable Key Repeat
defaults write -g ApplePressAndHoldEnabled -bool true
2015-10-18 13:28:55 -04:00
```
2015-12-03 19:26:24 -05:00
#### Key Repeat Rate
2015-10-18 13:36:50 -04:00
Sets a very fast repeat rate, adjust to taste.
```bash
defaults write NSGlobalDomain KeyRepeat -int 0.02
```
2015-09-24 12:11:34 -04:00
2015-09-22 17:23:45 -04:00
## Media
2015-09-24 12:11:34 -04:00
### Audio
#### Convert Audio File to iPhone Ringtone
2015-09-22 17:23:45 -04:00
```bash
afconvert input.mp3 ringtone.m4r -f m4af
```
2016-01-26 20:04:04 -05:00
#### Create Audiobook From Text
Uses "Alex" voice, a plain UTF-8 encoded text file for input and AAC output.
```bash
say -v Alex -f file.txt -o "output.m4a"
```
2015-10-17 13:01:31 -04:00
#### Disable Sound Effects on Boot
2015-10-17 16:17:55 -04:00
```bash
2015-10-17 13:01:31 -04:00
sudo nvram SystemAudioVolume=" "
```
2015-10-14 20:09:41 -04:00
#### Mute Audio Output
```bash
osascript -e 'set volume output muted true'
```
#### Set Audio Volume
```bash
osascript -e 'set volume 4'
```
2015-09-28 19:50:05 -04:00
#### Play Audio File
You can play all audio formats that are natively supported by QuickTime.
```bash
afplay -q 1 filename.mp3
```
2015-10-13 14:28:32 -04:00
#### Speak Text with System Default Voice
```bash
say 'All your base are belong to us!'
```
2015-10-18 13:07:05 -04:00
### Video
#### Auto-Play Videos in QuickTime Player
```bash
defaults write com.apple.QuickTimePlayerX MGPlayMovieOnOpen 1
```
2015-09-24 12:11:34 -04:00
2015-09-22 17:23:45 -04:00
## Networking
2015-09-24 12:11:34 -04:00
### Bonjour
2015-09-22 17:23:45 -04:00
2015-12-03 19:29:54 -05:00
#### Bonjour Service
2015-09-23 16:11:23 -04:00
```bash
2015-12-03 19:29:54 -05:00
# Disable
sudo defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist ProgramArguments -array-add "-NoMulticastAdvertisements"
2015-09-23 16:11:23 -04:00
2015-12-03 19:29:54 -05:00
# Enable (Default)
sudo defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist ProgramArguments -array "/usr/sbin/mDNSResponder" "-launchd"
```
2015-09-24 12:11:34 -04:00
### DHCP
#### Renew DHCP Lease
2015-09-22 17:23:45 -04:00
```bash
sudo ipconfig set en0 DHCP
```
2015-09-24 12:11:34 -04:00
#### Show DHCP Info
2015-09-22 17:23:45 -04:00
```bash
ipconfig getpacket en0
```
2015-09-24 12:11:34 -04:00
### DNS
#### Clear DNS Cache
```bash
2015-10-18 16:09:58 -04:00
sudo dscacheutil -flushcache && \
sudo killall -HUP mDNSResponder
2015-09-24 12:11:34 -04:00
```
2015-10-02 19:14:03 -04:00
### Hostname
#### Set Computer Name/Host Name
2015-10-02 19:14:03 -04:00
```bash
2015-10-18 16:09:58 -04:00
sudo scutil --set ComputerName "newhostname" && \
sudo scutil --set HostName "newhostname" && \
sudo scutil --set LocalHostName "newhostname" && \
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "newhostname"
2015-10-02 19:14:03 -04:00
```
### Network Preferences
#### Network Locations
Switch between network locations created in the Network preference pane.
```bash
# Status
scselect
# Switch Network Location
scselect LocationNameFromStatus
```
2015-10-13 17:32:14 -04:00
### Networking Tools
2015-09-24 12:11:34 -04:00
#### Ping a Host to See Whether Its Available
```bash
ping -o github.com
```
#### Troubleshoot Routing Problems
```bash
traceroute github.com
```
2016-05-08 12:39:25 -04:00
### SSH
#### Remote Login
```bash
# Enable remote login
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
# Disable remote login
sudo launchctl unload -w /System/Library/LaunchDaemons/ssh.plist
```
2015-10-13 17:45:59 -04:00
### TCP/IP
#### Show Application Using a Certain Port
This outputs all applications currently using port 80.
```bash
sudo lsof -i :80
```
#### Show External IP Address
```bash
dig +short myip.opendns.com @resolver1.opendns.com
```
2015-09-24 12:11:34 -04:00
### Wi-Fi
2015-11-03 12:07:29 -05:00
#### Join a Wi-Fi Network
```bash
networksetup -setairportnetwork en0 WIFI_SSID WIFI_PASSWORD
```
2015-10-02 16:19:51 -04:00
#### Scan Available Access Points
Create a symbolic link to the airport command for easy access:
```bash
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport
```
Run a wireless scan:
```bash
airport -s
```
#### Show Current SSID
```bash
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'
```
#### Show Local IP Address
```bash
ipconfig getifaddr en0
```
2015-09-24 12:11:34 -04:00
#### Show Wi-Fi Connection History
2015-09-22 17:23:45 -04:00
```bash
defaults read /Library/Preferences/SystemConfiguration/com.apple.airport.preferences | grep LastConnected -A 7
```
2015-09-24 12:11:34 -04:00
#### Show Wi-Fi Network Passwords
Exchange SSID with the SSID of the access point you wish to query the password from.
2015-09-22 17:23:45 -04:00
```bash
security find-generic-password -D "AirPort network password" -a "SSID" -gw
2015-09-22 17:23:45 -04:00
```
2015-11-03 12:07:29 -05:00
#### Turn on Wi-Fi Adapter
```bash
networksetup -setairportpower en0 on
```
2015-09-22 17:23:45 -04:00
## Package Managers
2015-09-24 12:11:34 -04:00
- [Fink](http://www.finkproject.org) - The full world of Unix Open Source software for Darwin.
- [Homebrew](http://brew.sh) - The missing package manager for OS X.
- [MacPorts](https://www.macports.org) - Compile, install and upgrade either command-line, X11 or Aqua based open-source software.
2015-09-22 17:23:45 -04:00
2015-10-17 13:23:10 -04:00
2015-09-22 17:23:45 -04:00
## Printing
2015-09-24 12:11:34 -04:00
#### Clear Print Queue
2015-09-22 17:23:45 -04:00
```bash
cancel -a -
```
#### Expand Print Panel by Default
```bash
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true && \
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
```
2015-10-18 16:25:24 -04:00
#### Quit Printer App After Print Jobs Complete
2015-10-17 13:23:10 -04:00
```bash
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
```
2015-09-22 17:23:45 -04:00
## Security
### Application Firewall
2015-12-03 19:32:14 -05:00
#### Firewall Service
```bash
2015-12-03 19:32:14 -05:00
# Show Status
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
2015-12-03 19:32:14 -05:00
# Enable
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
2015-12-03 19:32:14 -05:00
# Disable (Default)
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
```
#### Add Application to Firewall
```bash
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /path/to/file
```
2015-09-24 12:11:34 -04:00
### Gatekeeper
#### Add Gatekeeper Exception
2015-09-22 17:23:45 -04:00
```bash
spctl --add /path/to/Application.app
```
2015-09-24 12:11:34 -04:00
#### Remove Gatekeeper Exception
2015-09-22 17:23:45 -04:00
```bash
2015-09-24 12:11:34 -04:00
spctl --remove /path/to/Application.app
2015-09-22 17:23:45 -04:00
```
2015-09-25 10:17:11 -04:00
### Passwords
#### Generate Secure Password and Copy to Clipboard
First, install `pwgen` via Homebrew, etc.
```bash
pwgen -Cs 20 1 | tr -d ' ' | tr -d '\n' | pbcopy
```
2015-10-14 20:13:52 -04:00
### Physical Access
#### Launch Screen Saver
2015-10-14 20:13:52 -04:00
```bash
open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app
2015-10-14 20:13:52 -04:00
```
#### Lock Screen
```bash
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
```
2015-12-30 16:59:39 -05:00
#### Screensaver Immediate Lock
```bash
# Status
defaults read com.apple.screensaver askForPasswordDelay
# Enable (Default)
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Disable (Integer = lock delay in seconds)
defaults write com.apple.screensaver askForPasswordDelay -int 10
```
2015-12-30 16:56:32 -05:00
#### Screensaver Password
```bash
# Status
defaults read com.apple.screensaver askForPassword
# Enable
defaults write com.apple.screensaver askForPassword -int 1
# Disable (Default)
defaults write com.apple.screensaver askForPassword -int 0
```
2015-09-24 12:11:34 -04:00
### Wiping Data
#### Securely Remove File
2015-09-22 17:23:45 -04:00
```bash
srm /path/to/file
2015-09-24 12:11:34 -04:00
```
2015-10-18 16:15:38 -04:00
#### Securely Remove Folder
2015-09-24 12:11:34 -04:00
```bash
2015-10-18 16:15:38 -04:00
srm -r /path/to/folder/
2015-09-24 12:11:34 -04:00
```
#### Securely Remove Path (Force)
```bash
2015-09-22 17:23:45 -04:00
srm -rf /path/to/complete/destruction
```
2015-09-24 12:11:34 -04:00
## Search
2015-10-14 19:46:18 -04:00
### Find
#### Recursively Delete .DS_Store Files
```bash
find . -type f -name '*.DS_Store' -ls -delete
```
### Locate
#### Build Locate Database
```bash
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
```
#### Search via Locate
The `-i` modifier makes the search case insensitive.
```bash
locate -i *.jpg
```
2015-09-22 17:23:45 -04:00
## System
2015-10-18 11:50:45 -04:00
### AirDrop
```bash
2015-12-30 16:48:56 -05:00
# Enable AirDrop over Ethernet and on Unsupported Macs
2015-10-18 11:50:45 -04:00
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
2015-12-30 16:48:56 -05:00
# Enable (Default)
defaults remove com.apple.NetworkBrowser DisableAirDrop
# Disable
2015-12-30 17:13:43 -05:00
defaults write com.apple.NetworkBrowser DisableAirDrop -bool YES
2015-10-18 11:50:45 -04:00
```
2015-10-13 14:24:24 -04:00
### AppleScript
#### Execute AppleScript
```bash
osascript /path/to/script.scpt
2015-10-13 17:32:14 -04:00
```
2015-10-13 14:24:24 -04:00
2015-09-24 12:11:34 -04:00
### Basics
#### Restart
2015-09-22 17:23:45 -04:00
```bash
2015-09-24 12:11:34 -04:00
sudo reboot
2015-09-22 17:23:45 -04:00
```
2015-09-24 12:11:34 -04:00
#### Shutdown
2015-09-22 17:23:45 -04:00
```bash
2015-09-24 12:11:34 -04:00
sudo poweroff
2015-09-22 17:23:45 -04:00
```
2015-09-24 12:11:34 -04:00
#### Show Build Number of OS
```bash
sw_vers
```
2015-10-19 19:18:31 -04:00
#### Uptime
How long since your last restart.
```bash
uptime
```
2015-09-24 12:11:34 -04:00
### Clipboard
#### Copy data to Clipboard
2015-09-22 17:23:45 -04:00
```bash
cat whatever.txt | pbcopy
```
2015-11-04 12:56:24 -05:00
#### Convert Clipboard to Plain Text
```bash
pbpaste | textutil -convert txt -stdin -stdout -encoding 30 | pbcopy
```
2015-09-24 12:55:54 -04:00
#### Convert Tabs to Spaces for Clipboard Content
2015-09-24 12:38:36 -04:00
```bash
pbpaste | expand | pbcopy
```
2015-09-24 12:11:34 -04:00
#### Copy data from Clipboard
2015-09-23 16:18:00 -04:00
```bash
2015-09-24 12:11:34 -04:00
pbpaste > whatever.txt
2015-09-23 16:18:00 -04:00
```
2015-09-24 12:35:59 -04:00
#### Sort and Strip Duplicate Lines from Clipboard Content
```bash
pbpaste | sort | uniq | pbcopy
```
2015-09-24 12:11:34 -04:00
### FileVault
#### Automatically Unlock FileVault on Restart
If FileVault is enabled on the current volume, it restarts the system, bypassing the initial unlock. The command may not work on all systems.
2015-09-23 16:23:58 -04:00
```bash
sudo fdesetup authrestart
2015-09-23 16:23:58 -04:00
```
2015-12-03 19:39:57 -05:00
#### FileVault Service
```bash
2015-12-03 19:39:57 -05:00
# Status
sudo fdesetup status
2015-12-03 19:39:57 -05:00
# Enable
sudo fdesetup enable
# Disable (Default)
sudo fdestatus disable
```
2015-09-24 12:11:34 -04:00
### Information/Reports
#### Generate Advanced System and Performance Report
2015-09-22 17:23:45 -04:00
```bash
2015-09-24 12:11:34 -04:00
sudo sysdiagnose -f ~/Desktop/
2015-09-22 17:23:45 -04:00
```
2015-09-24 12:59:05 -04:00
### Kernel Extensions
#### Display Status of Loaded Kernel Extensions
2015-10-29 14:09:41 -04:00
```bash
sudo kextstat -l
```
2015-09-24 12:59:05 -04:00
#### Load Kernel Extension
```bash
sudo kextload -b com.apple.driver.ExampleBundle
```
#### Unload Kernel Extensions
```bash
sudo kextunload -b com.apple.driver.ExampleBundle
```
2015-10-13 17:56:00 -04:00
### LaunchAgents
2015-12-03 18:39:20 -05:00
Please see [this file](launchagents.md).
2015-10-13 17:56:00 -04:00
### LaunchServices
#### Rebuild LaunchServices Database
2015-10-14 19:02:36 -04:00
To be independent of OS X version, this relies on `locate` to find `lsregister`. If you do not have your `locate` database built yet, [do it](#build-locate-database).
```bash
sudo $(locate lsregister) -kill -seed -r
```
2015-10-13 17:56:00 -04:00
2015-10-29 12:36:13 -04:00
### Login Window
#### Set Login Window Text
```bash
sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "Your text"
```
2015-09-24 12:59:05 -04:00
### Memory Management
2015-09-24 12:11:34 -04:00
#### Purge memory cache
2015-09-22 17:23:45 -04:00
```bash
2015-09-24 12:11:34 -04:00
sudo purge
2015-09-22 17:23:45 -04:00
```
#### Show Memory Statistics
```bash
2015-12-03 17:13:46 -05:00
# One time
vm_stat
2015-12-03 17:13:46 -05:00
# Table of data, repeat 10 times total, 1 second wait between each poll
vm_stat -c 10 1
```
2015-09-24 12:11:34 -04:00
### Notification Center
2015-12-03 19:39:57 -05:00
#### Notification Center Service
2015-09-22 17:23:45 -04:00
```bash
2015-12-03 19:39:57 -05:00
# Disable
2015-10-18 16:09:58 -04:00
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist && \
killall -9 NotificationCenter
2015-09-22 17:23:45 -04:00
2015-12-03 19:39:57 -05:00
# Enable (Default)
2015-09-24 12:11:34 -04:00
launchctl load -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
2015-09-22 17:23:45 -04:00
```
2015-10-02 19:09:54 -04:00
### QuickLook
#### Preview via QuickLook
```bash
qlmanage -p /path/to/file
```
### Remote Apple Events
```bash
# Status
sudo systemsetup -getremoteappleevents
# Enable
sudo systemsetup -setremoteappleevents on
# Disable (Default)
sudo systemsetup -setremoteappleevents off
```
2015-09-24 12:11:34 -04:00
### Root User
2015-09-22 17:23:45 -04:00
```bash
2015-12-03 19:39:57 -05:00
# Enable
2015-09-24 12:11:34 -04:00
dsenableroot
2015-09-22 17:23:45 -04:00
2015-12-03 19:39:57 -05:00
# Disable
2015-09-24 12:11:34 -04:00
dsenableroot -d
2015-09-22 17:23:45 -04:00
```
2015-09-24 12:11:34 -04:00
### Safe Mode Boot
2015-09-22 17:23:45 -04:00
```bash
2015-12-03 19:39:57 -05:00
# Status
2015-09-24 12:11:34 -04:00
nvram boot-args
2015-09-22 17:23:45 -04:00
2015-12-03 19:39:57 -05:00
# Enable
2015-09-24 12:11:34 -04:00
sudo nvram boot-args="-x"
2015-09-22 17:23:45 -04:00
2015-12-03 19:39:57 -05:00
# Disable
2015-09-24 12:11:34 -04:00
sudo nvram boot-args=""
2015-09-22 17:23:45 -04:00
```
### Screenshots
#### Take Delayed Screenshot
2015-10-26 12:40:14 -04:00
Takes a screenshot as JPEG after 3 seconds and displays in Preview.
```bash
screencapture -T 3 -t jpg -P delayedpic.jpg
```
2015-10-20 03:08:13 -04:00
#### Save Screenshots to Given Location
2015-10-18 15:04:00 -04:00
Sets location to `~/Desktop`.
```bash
2015-10-20 03:08:51 -04:00
defaults write com.apple.screencapture location ~/Desktop && \
killall SystemUIServer
```
2015-10-22 12:54:30 -04:00
#### Save Screenshots in Given Format
2015-10-18 15:04:00 -04:00
Sets format to `png`. Other options are `bmp`, `gif`, `jpg`, `jpeg`, `pdf`, `tiff`.
```bash
defaults write com.apple.screencapture type -string "png"
```
2015-10-22 12:54:30 -04:00
#### Disable Shadow in Screenshots
```bash
2015-10-20 03:08:51 -04:00
defaults write com.apple.screencapture disable-shadow -bool true && \
killall SystemUIServer
```
2015-11-01 05:25:37 -05:00
#### Set Default Screenshot Name
Date and time remain unchanged.
```bash
defaults write com.apple.screencapture name "Example name" && \
killall SystemUIServer
```
2015-09-25 10:48:55 -04:00
### Software Installation
#### Install PKG
```bash
installer -pkg /path/to/installer.pkg -target /
```
2015-10-18 13:03:45 -04:00
### Software Update
2015-10-19 19:09:09 -04:00
#### Install All Available Software Updates
```bash
sudo softwareupdate -ia
```
2015-10-18 13:03:45 -04:00
#### Set Software Update Check Interval
Set to check daily instead of weekly.
```bash
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
```
2015-10-19 19:09:09 -04:00
#### Show Available Software Updates
```bash
sudo softwareupdate -l
```
2015-12-03 17:56:06 -05:00
#### Set Software Update Server
This should only be done for testing purposes or unmanaged clients. To use network-wide, either correctly set up DNS along with [Apple SUS service](http://krypted.com/mac-security/using-the-software-update-service-on-mountain-lion-server/) and bind your clients via OpenDirectory. Alternatively, use [Reposado](https://github.com/wdas/reposado) together with correct network DNS settings to make resolution transparent. [Margarita](https://github.com/jessepeterson/margarita) looks nice to have as well.
```bash
2015-12-03 17:56:06 -05:00
# Use own SUS
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL http://su.example.com:8088/index.sucatalog
# Reset to Apple SUS
sudo defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL
```
2015-10-13 14:20:04 -04:00
### Spotlight
2015-12-03 19:39:57 -05:00
#### Spotlight Indexing
2015-10-13 14:20:04 -04:00
```bash
2015-12-03 19:39:57 -05:00
# Disable
2015-10-13 14:20:04 -04:00
mdutil -i off -d /path/to/volume
2015-12-03 19:39:57 -05:00
# Enable (Default)
2015-10-13 14:20:04 -04:00
mdutil -i on /path/to/volume
```
#### Erase Spotlight Index and Rebuild
```bash
mdutil -E /path/to/volume
```
#### Search via Spotlight
```bash
mdfind -name 'searchterm'
```
2016-02-08 22:05:42 -05:00
#### Show Spotlight Indexed Metadata
```bash
mdls /path/to/file
```
### System Integrity Protection
#### Disable System Integrity Protection
2015-10-24 20:54:05 -04:00
Reboot while holding <kbd>Cmd</kbd> + <kbd>R</kbd>, open the Terminal application and enter:
```bash
csrutil disable && reboot
```
#### Enable System Integrity Protection
2015-10-24 20:54:05 -04:00
Reboot while holding <kbd>Cmd</kbd> + <kbd>R</kbd>, open the Terminal application and enter:
```bash
csrutil enable && reboot
```
### Date and Time
2015-12-30 16:52:08 -05:00
#### List Available Timezones
```bash
sudo systemsetup -listtimezones
```
#### Set Timezone
```bash
sudo systemsetup -settimezone Europe/Berlin
```
#### Set Clock Using Network Time
2015-12-30 16:52:08 -05:00
```bash
# Status
sudo systemsetup getusingnetworktime
# Enable (Default)
sudo systemsetup setusingnetworktime on
# Disable
sudo systemsetup setusingnetworktime off
```
2015-10-13 17:32:14 -04:00
2015-10-14 20:04:21 -04:00
## Terminal
#### Ring Terminal Bell
Rings the terminal bell (if enabled) and puts a badge on it.
```bash
tput bel
```
### Alternative Terminals
- [iTerm2](https://iterm2.com) - A better Terminal.app.
- [TotalTerminal](http://totalterminal.binaryage.com) - A system-wide terminal available on a hot-key. (Requires System Integrity Protection be disabled. If you don't want to disable it, iTerm2 also has this feature.)
2015-10-18 16:47:54 -04:00
### Shells
#### Bash
Install the latest version and set as current users' default shell:
```bash
brew install bash && \
sudo echo $(brew --prefix)/bin/bash >> /etc/shells && \
chsh -s $(brew --prefix)/bin/bash
```
- [Homepage](https://www.gnu.org/software/bash/) - The default shell for OS X and most other Unix-based operating systems.
2016-03-12 17:41:13 -05:00
- [Bash-it](https://github.com/Bash-it/bash-it) - Community Bash framework, like Oh My Zsh for Bash.
2015-10-18 16:47:54 -04:00
#### fish
Install the latest version and set as current users' default shell:
2015-10-18 16:47:54 -04:00
```bash
brew install fish && \
echo $(brew --prefix)/bin/fish | sudo tee -a /etc/shells && \
chsh -s $(brew --prefix)/bin/fish
2015-10-18 16:47:54 -04:00
```
- [Homepage](http://fishshell.com) - A smart and user-friendly command line
shell for OS X, Linux, and the rest of the family.
2016-02-23 12:53:25 -05:00
- [Fisherman](http://fisherman.sh) - A blazing fast, modern plugin manager for Fish.
2015-10-18 16:47:54 -04:00
- [The Fishshell Framework](https://github.com/oh-my-fish/oh-my-fish) - Provides core infrastructure to allow you to install packages which extend or modify the look of your shell.
#### Zsh
Install the latest version and set as current users' default shell:
2015-10-18 16:47:54 -04:00
```bash
brew install zsh && \
2015-10-29 13:31:01 -04:00
sudo sh -c 'echo $(brew --prefix)/bin/zsh >> /etc/shells' && \
chsh -s $(brew --prefix)/bin/zsh
2015-10-18 16:47:54 -04:00
```
- [Homepage](http://www.zsh.org) - Zsh is a shell designed for interactive use, although it is also a powerful scripting language.
2015-10-19 21:23:52 -04:00
- [Oh My Zsh](http://ohmyz.sh) - An open source, community-driven framework for managing your Zsh configuration.
- [Prezto](https://github.com/sorin-ionescu/prezto) - A speedy Zsh framework. Enriches the command line interface environment with sane defaults, aliases, functions, auto completion, and prompt themes.
- [zgen](https://github.com/tarjoilija/zgen) - Another open source framework for managing your zsh configuration. Zgen will load oh-my-zsh compatible plugins and themes and has the advantage of both being faster and automatically cloning any plugins used in your configuration for you.
2015-10-18 16:47:54 -04:00
### Terminal Fonts
2015-10-18 12:37:13 -04:00
- [Anonymous Pro](http://www.marksimonson.com/fonts/view/anonymous-pro) - A family of four fixed-width fonts designed with coding in mind.
- [Codeface](https://github.com/chrissimpkins/codeface) - A gallery and repository of monospaced fonts for developers.
- [DejaVu Sans Mono](http://dejavu-fonts.org/wiki/Main_Page) - A font family based on the Vera Fonts.
2015-10-18 12:37:13 -04:00
- [Hack](http://sourcefoundry.org/hack/) - Hack is hand groomed and optically balanced to be your go-to code face.
2015-10-18 13:49:18 -04:00
- [Inconsolata](http://levien.com/type/myfonts/inconsolata.html) - A monospace font, designed for code listings and the like.
2015-10-18 13:51:12 -04:00
- [Input](http://input.fontbureau.com) - A flexible system of fonts designed specifically for code.
2015-10-18 12:37:13 -04:00
- [Meslo](https://github.com/andreberg/Meslo-Font) - Customized version of Apple's Menlo font.
2015-10-29 12:48:12 -04:00
- [Powerline Fonts](https://github.com/powerline/fonts) - Repo of patched fonts for the Powerline plugin.
2015-10-20 20:21:58 -04:00
- [Source Code Pro](https://adobe-fonts.github.io/source-code-pro/) - A monospaced font family for user interfaces and coding environments.
2015-10-14 20:04:21 -04:00
2015-09-22 17:42:05 -04:00
## License
2016-02-29 05:49:33 -05:00
<a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.