Skip to content

Latest commit

 

History

History
145 lines (113 loc) · 3.18 KB

mac.md

File metadata and controls

145 lines (113 loc) · 3.18 KB

Hide a file/folder

# Hide
chflags hidden '<FILE_NAME>'

# Show
chflags nohidden '<FILE_NAME>'

Make password-protected, encypted zips

# Encypt and zip two files
zip -e '<ARCHIVE>.zip' 'input1.txt' 'input2.txt'

# Encypt and zip a directory
zip -er '<ARCHIVE>.zip' '<PATH_TO_DIRECTORY>'

Software Update via Terminal

# Check for new updates
softwareupdate -l

# Install an update
softwareupdate -i '<FULL_NAME_OF_UPDATE>'

# Install all available updates
softwareupdate -ai

# List recent update history
softwareupdate --history

Show information about a volume

diskutil info '<PATH_TO_VOLUME>'

SMB

# List information about all SMB shares we're currently connected to
smbutil statshares -a

Get summed lengths of videos in folders of current dir

for d in */ ; do
	mdls "$d"/*.mov | grep Duration | awk '{ print $3 }' | paste -s -d+ - | bc
done

Get info about the Mac

# general hardware information
system_profiler SPHardwareDataType

# show info about battery cycles and/or connected AC adapter
system_profiler SPPowerDataType

# show name of CPU
sysctl -n machdep.cpu.brand_string

# show arch
uname -m

# get macOS version
sw_vers -productVersion

Xcode

# Uninstall Xcode CLT
sudo rm -rf "/Library/Developer/CommandLineTools"

# Get version of Swift that Xcode is using
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version

WiFi info

# Show Available WiFi Networks
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s

# Get information about current WiFi connection
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I

Change Wallpaper

osascript -e 'tell application "Finder" to set desktop picture to POSIX file "<ABSOLUTE_PATH_TO_JPG>"'

Gatekeeper

# enable
sudo spctl --master-enable

# disable
sudo spctl --master-disable

# ad-hoc sign a binary (i.e. disable signature check for specific app)
sudo codesign -f -s - '<PATH_TO_APP>/Contents/MacOS/<APP_BINARY>'

# perform security assessment on app
spctl --assess -vv "<PATH_TO_APP>/App.app"

# Get verbose info about app's signing status
codesign -d --deep --verbose=2 -r- "<PATH_TO_APP>/App.app"

Reset local account password

# Recovery mode -> Terminal.  Can't be locked with Apple ID.
resetpassword

sips

# Convert a single file from heic to jpg, highest quality
sips -s format jpeg -s formatOptions best -m "/System/Library/ColorSync/Profiles/Display P3.icc" '<INPUT_FILE>.heic' -o '<OUTPUT_FILE>.jpg>'

# Convert multiple files from heic to jpg, highest quality
sips -s format jpeg -s formatOptions best -m "/System/Library/ColorSync/Profiles/Display P3.icc" '<INPUT_1.HEIC>' '<INPUT_2.HEIC>' -o '<OUTPUT_DIR>/'

plutil

# Print contents of a plist in a human readable format
plutil -p '<PATH_TO_PLIST>'

# Print a binary plist in XML format
plutil -convert xml1 -o - '<PATH_TO_PLIST>'

Internet speed test

# uses Apple's servers
networkQuality -v

open

# reveal the file in a new finder window
open -R '<PATH_TO_FILE>'