Further Gnome Command-Line Integration

Updated: Sun, Jul 27, 2008 - 6:49pm

In a previous post, I talked about my command-line program that opens files in the same manner as gnome would if you had double-clicked it in nautilus.
I have another piece of integration that I'd like to see: Clipboard integration.

The Problem

I'm always editing text files in vim, or viewing them in less, in a terminal window. Sometimes, though, I want to take that file and copy it to the clipboard so that I can paste it into, say, a textarea in my web browser.
I could normally just drag my mouse, or select all, or whatever, then copy/paste. But using the terminal breaks that metaphor, because selecting all just selects all the things on the screen (or at most the scrollback buffer). If my file is longer than the screen or the scrollback buffer, it's difficult to get it onto the clipboard.
What I usually do in that situation is to open the file in gedit and then select all, copy, then paste. Pain in the butt!

The Solution

Why not skip the middleman? make a program that runs on the command line, takes stuff from stdin (or a named file), and then uses the gnome or X11 apis to put that text onto the clipboard. Easy as pie.

  1. % cat blog-entry-I-wrote-offline.txt | enclip

Your rating: None Average: 5 (1 vote)

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
                    _                     _ 
___ __ __ | |_ _ __ __ _ | |
/ _ \ \ \ /\ / / | __| | '_ \ / _` | | |
| __/ \ V V / | |_ | |_) | | (_| | | |
\___| \_/\_/ \__| | .__/ \__, | |_|
|_| |___/
Enter the code depicted in ASCII art style.