Is it possible to capture bash output to the OS X clipboard?
Command-C and Command-V work as expected if you can get the output selected, though. Command-C and Command-V works fine but you have to select the output using your mouse as you mentioned.
pbcopy will allow you to copy the output of a command right into your clipboard. Vice-versa for pbpaste — it will allow you to paste your clipboard right into your terminal. # This will copy all the content within a file. $ cat myfile. txt | pbcopy# This will output the contents of your clipboard.
And yes you can do use the pbcopy and pbpaste commands at the terminal and then interact with them again from the GUI of MacOS by using the standard Mac copy and paste keyboard shortcuts of Command+C and Command+V. It goes the other direction too, a copy from the GUI can be pasted with pbpaste at the command line.
The pbcopy command does this.
For example, this puts the output from ls
on the clipboard/pasteboard:
ls | pbcopy
And pbpaste does the reverse, writing to stdout from the clipboard:
pbpaste > ls.txt
You can use both together to filter content on the clipboard - here's a rot13:
pbpaste | tr 'a-zA-Z' 'n-za-mN-ZA-M' | pbcopy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With