You are not logged in.

#1 2008-11-03 17:31:11

Reploid
Member
From: Cold Country up North
Registered: 2008-03-27
Posts: 110

Copy/Paste in terminal without using mouse!

Scuse me, this a very n00by question:

When I type "sudo iwlist wlan0 scan," I get a list of different access points in my vicinity. Instead of using a mouse to copy/paste the mac addresses when typing in commands, I would have loved to use keyboard input only. How is that possible?

Offline

#2 2008-11-03 18:05:56

phabulosa
Member
From: Mountain View, CA
Registered: 2007-10-17
Posts: 182
Website

Re: Copy/Paste in terminal without using mouse!

Try to use GNU screen and it gets a neat feature of "cut and paste"
Or you can use mouse to select the text and press "shift + insert" to paste, it has the same effect as the middle click.

Offline

#3 2008-11-03 18:16:37

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Copy/Paste in terminal without using mouse!

You could pipe it to xsel -i, maybe grep for HWaddr first, and it's available for Shift+Insert then.

Offline

#4 2008-11-03 18:28:32

Reploid
Member
From: Cold Country up North
Registered: 2008-03-27
Posts: 110

Re: Copy/Paste in terminal without using mouse!

The GNU screen would require me to have started X, right?

Procyon: what does "pipe it" mean? | grep HWaddr lists only the HWaddr and strips away the other stuff, right?

Offline

#5 2008-11-03 19:56:52

bluewind
Administrator
From: Austria
Registered: 2008-07-13
Posts: 172
Website

Re: Copy/Paste in terminal without using mouse!

Reploid wrote:

The GNU screen would require me to have started X, right?

Screen doesn't need any X. You can run it in an vt if you want to.

Reploid wrote:

Procyon: what does "pipe it" mean? | grep HWaddr lists only the HWaddr and strips away the other stuff, right?

yes

pipe = |
A pipe passes the output of a program to another one.

Last edited by bluewind (2008-11-03 19:58:44)

Offline

#6 2008-11-03 20:24:54

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Copy/Paste in terminal without using mouse!

Well xsel needs X, so that won't do.

If you do use it for such a task, then also be careful of newlines. Pipe it to xargs echo -n first. So ifconfig | grep HWaddr | xargs echo -n | xsel -i

Offline

#7 2008-11-04 04:10:02

phabulosa
Member
From: Mountain View, CA
Registered: 2007-10-17
Posts: 182
Website

Re: Copy/Paste in terminal without using mouse!

Reploid wrote:

The GNU screen would require me to have started X, right?

Procyon: what does "pipe it" mean? | grep HWaddr lists only the HWaddr and strips away the other stuff, right?

Read Manpage of Screen. Trust me, it will be very rewarding in the long run.

"Ctrl A, [" takes you to "selection mode" and use vi-like keybinding to select the text.
"Ctrl A, ]" will paste the selected text.

Offline

#8 2008-11-04 09:58:27

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: Copy/Paste in terminal without using mouse!

Especially note the ^a, ? binding to bring up the help menu. There's only 2 or 3 core bindings you have to remember to get started with screen.

Offline

#9 2008-11-04 11:42:25

dav7
Member
From: Australia
Registered: 2008-02-08
Posts: 674

Re: Copy/Paste in terminal without using mouse!

Procyon wrote:

...also be careful of newlines. Pipe it to xargs echo -n first. So ifconfig | grep HWaddr | xargs echo -n | xsel -i

Or you could use quotes, eg

echo $(ls)

looks REALLY bad, but

echo "$(ls)"

is fine.

-dav7


Windows was made for looking at success from a distance through a wall of oversimplicity. Linux removes the wall, so you can just walk up to success and make it your own.
--
Reinventing the wheel is fun. You get to redefine pi.

Offline

Board footer

Powered by FluxBB