Copy Shell Output via the Command Line
Oftentimes I'll want to copy the output of a shell command execution but can't get the whole output because it's larger than the terminal's buffer length, so I'll need to write to file for easy viewing, or I'll simply be annoyed that I have to click-hold-drag to copy the output. Shouldn't there be an easier way? There is: pbcopy and clip. Using pbcopy within the shell, the output of an execution can automatically be added to the copy queue (or clipboard):
# Copy the source of davidwalsh.name to the clipboard on Mac
curl davidwalsh.name | pbcopy
# Copy the source of davidwalsh.name to the clipboard on Windows
curl davidwalsh.name | clip
Piping pbcopy at the end of the command makes this magic possible. So what do I look forward to using this for? My colleague Luke showed me how he gets the commit hash from the master branch without needing to go to GitHub to get it:
alias ghash='git rev-parse HEAD && git rev-parse HEAD | pbcopy'
I look forward to using pbcopy more -- an excellent utility to allow me to avoid lame cursor click-hold-drag to get the output I want!
![CSS 3D Folding Animation]()
Google Plus provides loads of inspiration for front-end developers, especially when it comes to the CSS and JavaScript wonders they create. Last year I duplicated their incredible PhotoStack effect with both MooTools and pure CSS; this time I'm going to duplicate...
![Interview with a Pornhub Web Developer]()
Regardless of your stance on pornography, it would be impossible to deny the massive impact the adult website industry has had on pushing the web forward. From pushing the browser's video limits to pushing ads through WebSocket so ad blockers don't detect them, you have...
![Create a Photo Stack Effect with Pure CSS Animations or MooTools]()
My favorite technological piece of Google Plus is its image upload and display handling. You can drag the images from your OS right into a browser's DIV element, the images upload right before your eyes, and the albums page displays a sexy photo deck animation...
![Dijit’s TabContainer Layout: Easy Tabbed Content]()
One of Dojo's major advantages over other JavaScript toolkits is its Dijit library. Dijit is a UI framework comprised of JavaScript widget classes, CSS files, and HTML templates. One very useful layout class is the TabContainer. TabContainer allows you to quickly create a tabbed content...
It may be silly to notice that this isn’t for Windows…
Might be worth adding instructions using
xcopy
on Linux, andclip
on WindowsI am on Linux and I use http://www.vergenet.net/~conrad/software/xsel/
Use it like this:
curl davidwalsh.name | xsel –clipboard –input
You can also alias is so you can use pbcopy
To do that add alias pbcopy=’xsel –clipboard –input’ to your ~/:bashrc
windows would be curl davidwalsh.name | clip
assuming you had curl for windows installed ;)