If you are at least lazy as me and you use macosx and you hate the mouse I just found this little “shortcut”.
Just go to your favorite terminal and do something like that:
sh-3.2# pbcopy < file
Now in your copy buffer you have your text file (pbcopy defaults to ASCII, see man pbcopy for further informations) and you can paste it everywhere you want or using pbpaste from terminal.
Of course you can also put them in pipes, as for example this deletes comments from a shells script and puts the result in the copy buffer:
sh-3.2# grep -v '^#' file | pbpaste
Otherwise you should:
This is much faster, isn’t it?
pbpaste is nice and this is a good tip, apart from the ‘useless use of cat’. You’re making your OS perform twice the work by having cat read in the entire file and then write it out again to pbpaste, which has to read it from its stdin filedescriptor (read(), write() and read() calls). A much nicer way of feeding the contents of a file to any unixy command which reads from stdin is to instruct your shell to redirect the stdin of a command to a file, which will allow pbpaste to immediately read it (so the data is only read once and not read, written and read again) (cheap dup()/dup2() and read()):
# works on sh and csh
$ <file command
$ <file pbpaste
See also this hilarious (well, for geeks, anyway) presentation by a NetBSD developer: http://www.netmeister.org/misc/useless_use.pdf
Thanks a lot you’re right (I corrected it).
I just wanted to show that there is a shell command to work on the copy/paste buffer basically.
I remember years ago I asked for something like that on linux but nobody answered, and the question looked weird (but for me it was useful).
Something like pbcopy/pbpaste is not shipped by default with X11′s packages. However, on Linux/BSD systems, you should find the `xclip’ utility in your distribution’s package repository, and if not, on sourceforge: http://sourceforge.net/projects/xclip . It’s basically the same as pbcopy/pbpaste.
See http://linux.die.net/man/1/xclip for the man page.