Clipboard, Spotlight & Disk Tools from the Terminal — Zsh #28
Video: Clipboard, Spotlight & Disk Tools from the Terminal — Zsh #28 by Taught by Celeste AI - AI Coding Coach
Watch full page →Clipboard, Spotlight & Disk Tools from the Terminal — Zsh #28
Discover powerful macOS terminal commands to manage system info, clipboard, productivity, Spotlight search, and disk utilities using Zsh. This guide covers practical commands like pbcopy and pbpaste for clipboard operations, mdfind for Spotlight searches, and diskutil for disk management, all demonstrated with concise examples you can run directly on your Mac.
Code
# Display macOS version info
sw_vers
# Get detailed hardware info (model, memory, chip)
system_profiler SPHardwareDataType
# Show computer name and local hostname
scutil --get ComputerName
scutil --get LocalHostName
# Read and write a system preference (example: show hidden files in Finder)
defaults read com.apple.finder AppleShowAllFiles
defaults write com.apple.finder AppleShowAllFiles -bool true
killall Finder # Restart Finder to apply changes
# Copy command output to clipboard and paste it back
echo "Hello from terminal!" | pbcopy
pbpaste
# Open a URL or file with default app
open https://apple.com
open ~/Documents
# Use text-to-speech to say a phrase aloud
say -v Alex "Welcome to macOS terminal commands!"
# Prevent Mac from sleeping for 1 hour
caffeinate -t 3600 &
# Take a screenshot saved to Desktop
screencapture ~/Desktop/terminal_screenshot.png
# Search files using Spotlight for 'report'
mdfind "report"
# List all disks and volumes
diskutil list
# Mount a disk image (.dmg file)
hdiutil attach ~/Downloads/example.dmg
# Unmount a disk image
hdiutil detach /Volumes/ExampleVolume
Key Points
sw_versandsystem_profilerprovide detailed macOS and hardware information.pbcopyandpbpasteenable seamless clipboard integration in terminal workflows.openlaunches files, folders, or URLs with their default applications from the terminal.mdfindleverages Spotlight to quickly search for files and content on your Mac.diskutilandhdiutilmanage disks and disk images directly via command line.