Skip to content

Instantly share code, notes, and snippets.

@nprasad2077
Created July 14, 2023 22:19
Show Gist options
  • Save nprasad2077/a3bca17e73c9e90e0ac103a9edc33826 to your computer and use it in GitHub Desktop.
Save nprasad2077/a3bca17e73c9e90e0ac103a9edc33826 to your computer and use it in GitHub Desktop.

Bash Command Shortcuts Documentation

Repair Permissions

sudo diskutil repairPermissions /

List All Disks/Partitions

diskutil list

View File System Usage

sudo fs_usage

Create Temporary High Performance Disk

The disk is backed by physical RAM and will be several times faster than an SSD. The contents of the disk cannot be recovered after it has been ejected. The example below is for a 500 MiB RAM disk, adjust as needed.

Up to macOS 10.14 (Mojave)

let DISKSIZE=500*2048 && \
diskutil erasevolume HFS+ "RAM Disk" `hdiutil attach -nomount ram://$DISKSIZE`

From macOS 10.15 (Catalina) on

let "DISKSIZE = 500*2048" && \
diskutil erasevolume HFS+ "RAM Disk" `hdiutil attach -nomount ram://$DISKSIZE`

Mount Disk Image

hdiutil attach /path/to/diskimage.dmg

Unmount Image

hdiutil detach /dev/disk2s1

Write Image to Volume (Restore)

sudo asr -restore -noverify -source /path/to/diskimage.dmg -target /Volumes/VolumeToRestoreTo

Show Network Volumes

Enable

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

Disable (Default)

defaults write com.apple.finder ShowMountedServersOnDesktop -bool false && \
killall Finder

Clear ACL

sudo chmod -RN /path/to/folder

Show All File Extensions

defaults write -g AppleShowAllExtensions -bool true

Set Protected Flag

This is equivalent to Finder "Locked" status.

Disable (Default)

sudo chflags -R nouchg /path/to/file/or/folder

Enable

sudo chflags -R uchg /path/to/file/or/folder

Show Hidden Files

Show All

defaults write com.apple.finder AppleShowAllFiles true

Restore Default File Visibility

defaults write com.apple.finder AppleShowAllFiles false

Toggle Folder Visibility in Finder

Hidden (Default)

chflags hidden ~/Library

Visible

chflags nohidden ~/Library

Desktop Show/Hide Icons

Hide Icons

defaults write com.apple.finder CreateDesktop -bool false && \
killall Finder

Show Icons (Default)

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

Set Current Folder as Default Search Scope

defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"

Set Default Finder Location to Home Folder

defaults write com.apple.finder NewWindowTarget -string "PfLo" && \
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}"

Convert Audio File to iPhone Ringtone

afconvert input.mp3 ringtone.m4r -f m4af

Create Audiobook from Text using 'Alex' Voice

say -v Alex -f file.txt -o "output.m4a"

Say Anything

say 'hello'
say -f mynovel.txt -o myaudiobook.aiff

Advanced System Performance Report

sudo sysdiagnose -f ~/Desktop/

Purge Memory Cache

sudo purge

Copy Terminal File Directory

ls ~ | pbcopy

Spotlight Search in Directory

mdfind -onlyin ~/Documents essay

Screen Capture

screencapture -C -M image.png
screencapture -c -W
screencapture -T 10 -P image.png
screencapture -s -t pdf image.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment