MyTetra Share
Делитесь знаниями!
How can I copy the output of a command directly into my clipboard?
Время создания: 26.09.2017 09:24
Текстовые метки: linux cli terminal copy clipboard
Раздел: Linux
Запись: Velonski/mytetra-database/master/base/1506399872nzmytj51q8/text.html на raw.githubusercontent.com

I always wanted to do this and found a nice and easy way of doing it. I wrote down the complete procedure just in case anyone else needs it.

First install a 16 kB program called xclip:

sudo apt-get install xclip

You can then pipe the output into xclip to be copied into the clipboard:

cat file | xclip

To paste the text you just copied, you shall use:

xclip -o

To simplify life, you can set up an alias in your .bashrc file as I did:

alias "c=xclip"
alias "v=xclip -o"

To see how useful this is, imagine I want to open my current path in a new terminal window (there may be other ways of doing it like Ctrl+T on some systems, but this is just for illustration purposes):

Terminal 1:
pwd | c

Terminal 2:
cd `v`

Notice the ` ` around v. This executes v as a command first and then substitutes it in-place for cd to use.

Only copy the content to the X clipboard

cat file | xclip

If you want to paste somewhere else other than a X application, try this one:

cat file | xclip -selection clipboard
Так же в этом разделе:
 
MyTetra Share v.0.65
Яндекс индекс цитирования