Quickly Copy HTML & CSS Source to the Clipboard with curl
Using curl and pbcopy, we can quickly grab and copy HTML and CSS code from any URL via the command line. This should be a helpful tip for the web developers out there, but for anyone looking to check the source of a web page through this can be an invaluable little trick.
Getting HTML is just a matter of pointing curl to the URL in question, then piping the results to the pbcopy command like so:
curl "http://google.com/" | pbcopy
Of course you’ll want to replace the sample URL with your own. When the command has finished running, the HTML will now be in your clipboard (thanks to pbcopy) and ready for you to paste anywhere else.
Grabbing the CSS requires you to specify where the CSS file is located, otherwise the command is the same:
curl "http://google.com/css/stylesheet.css" | pbcopy
We’ve covered pbcopy & pbpaste a while ago, they’re just command line interfaces for the Mac OS X clipboard but combined with other scripts or utilities can be quite powerful.
This works in OS X, though it’s not directly compatible with linux because of the pbcopy command.