7

In order to minimize mouse usage (accessibility and health reasons), how can I pipe the standard out to the OS clip board?

That is, I'd like to do something like:

$ drush uli | copy-this-to-clipbaord

$ drush uli > copy-this-to-clipbaord

Possible?

TellMeWhy
  • 17,484
Rick
  • 2,847

3 Answers3

12

Install xsel either through the above link or through the terminal:

sudo apt-get install xsel

To copy the output of a command use:

*command* | xsel -ib

An example:

$ drush uli | xsel -ib

You can make it simpler by editing (create it if you don't already have it with touch ~/.bash_aliases) your ~/.bash_aliases file.
Add this line to it: alias clipboard = 'xsel -ib' (you can use any name, not just clipboard).

Once you've done so you can use: *command* | clipboard

TellMeWhy
  • 17,484
5

I use xclip.

Example:

bashscript.sh | xclip -sel clip
A.B.
  • 90,397
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
4

You can use xsel in just that way:

xsel -i -b >/dev/null
  • Option -i (--input) makes it read input from standard input
  • Option -b (--clipboard) makes it use the clipboard buffer instead the selection or one of the less commonly further buffers.
  • >/dev/null is hiding some annoying error message - not shure that can occur with these options set.

So, why not try

drush uli | xsel -i -b

and tell whether paste from clipboard pastes the right text!
I left out the part hiding errors for testing.

A.B.
  • 90,397
Volker Siegel
  • 13,065
  • 5
  • 49
  • 65