Paste Clipboard Text into a Command
What This Does
Use text from your clipboard as input to a command, turning copied text into data your terminal can work with.
Why It's Useful
Turn copied text into data. Copy a file path from Finder, an email address, or any text, then use it directly in terminal commands without retyping.
How to Do It
- Copy some text to your clipboard (like a file path from Finder)
- Use
pbpastein your command - For example:
cd $(pbpaste)changes to the directory you copied - Or:
cat $(pbpaste)displays the file whose path you copied
Try This Now
Copy a file path from Finder (right-click a file, hold Option, then choose "Copy as Pathname"). Then run ls $(pbpaste) to list that file's directory.
Mental Hook: Turn copied text into data.