Log.txt

My thoughts, stories, and geekeries in a .txt

XClip: Command-Line Access to X11 Clipboard

I worked with Vim a lot and I find it frustrating to copy an entire text file to clipboard. It’s easy to copy a small piece of code, because you just have to highlight and Ctrl+Shift+V. However, in case the code is too large to fit one window, you might have to scroll down and it might be frustrating to highlight.

Today I just discovered a simple nifty tool to copy texts from command-Line terminal to your X 11 Clipboard: xclip. To copy an entire text file to Clipboard, your command will be as simple as follow:

cat <text file> | xclip -selection clipboard

If you only want to copy a certain portion of your text file, it might be a little bit tricky. You might want to pipe your text output to a text processing tool like sed before going to xclip. At some point, it might be easier to just fire up gedit, do manual highlight and Ctrl-C.

Advertisements

Written by Andree

January 8, 2013 at 6:18 am

Posted in Linux

%d bloggers like this: