Skip to content

Instantly share code, notes, and snippets.

@colematt
Created October 20, 2025 17:59
Show Gist options
  • Save colematt/40336d9c3de3224bd2de2ee038f27441 to your computer and use it in GitHub Desktop.
Save colematt/40336d9c3de3224bd2de2ee038f27441 to your computer and use it in GitHub Desktop.

Using clipboard from shell in MacOS

Copy standard output to the clipboard

cat file.txt | pbcopy

Capture from standard error to the clipboard

cmd 2>&1 | pbcopy

Capture from stream to the clipboard

pbcopy < /file/to/stream

Paste from the clipboard

pbpaste > cat file.txt
pbpaste | tee file.txt

Filter content on the clipboard

# ROT-13 a text
pbpaste | tr 'a-zA-Z' 'n-za-mN-ZA-M' | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment