Last active
December 26, 2017 20:06
-
-
Save niedzielski/b5379452552c7ecbffed3cc7f0bbb089 to your computer and use it in GitHub Desktop.
Seamlessly work across GUIs and command line with copy and paste.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The clipboard provides a very convenient way to exchange data between | |
| # different programs and is especially convenient for working with GUIs | |
| # which can't use pipelines. Add the following function to your .zshrc / | |
| # .bashrc: | |
| cb() { | |
| # OS X: pbcopy / pbpaste | |
| # Cygwin: putclip / getclip | |
| # Linux: xclip (and others) | |
| if [[ ! -t 0 ]] | |
| then | |
| # Input (copy). | |
| xclip -sel c | |
| else | |
| # Output (paste). | |
| xclip -sel c -o | |
| fi | |
| } | |
| # Examples | |
| # Check for the existence of a collection of files. | |
| # $ ls $(cb) | |
| # Copy the webpage at the clipboard URL. | |
| # $ curl $(cb)|cb | |
| # Copy the concatenate of a collection of files. | |
| # $ cb|xargs -rd\\n cat|cb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment