Hack 5 Use the Mouse at a Terminal

figs/moderate.gif figs/hack5.gif

Use your mouse to copy and paste at a terminal.

If you're used to a GUI environment, you might feel a bit out of your element while working at the terminal. Sure, you can learn to map hotkeys and to use navigational tricks, but darn it all, sometimes it's just nice to be able to copy and paste!

Don't fret; your mouse doesn't have to go to waste. In fact, depending upon how you have configured your system, the mouse daemon moused may already be enabled. The job of this daemon is to listen for mouse data in order to pass it to your console driver.

Of course, if you're using screen [Hack #12], you can also take advantage of its copy and paste mechanism.

1.6.1 If X Is Already Installed

If you installed and configured X when you installed your system, moused is most likely started for you when you boot up. You can check with this:

% grep moused /etc/rc.conf moused_port="/dev/psm0" moused_type="auto" moused_enable="YES"

Very good. moused needs to know three things:

  • The mouse port (in this example, /dev/psm0, the PS/2 port)

  • The type of protocol (in this example, auto)

  • Whether to start at boot time

If you receive similar output, you're ready to copy and paste.

To copy text, simply select it by clicking the left mouse button and dragging. Then, place the mouse where you'd like to paste the text and click the middle button. That's it.

To select an entire word, double-click anywhere on that word. To select an entire line, triple-click anywhere on that line. Configuring a two-button mouse

What if you don't have three mouse buttons? As the superuser, add the following line to /etc/rc.conf (assuming it's not already there):

moused_flags="-m 2=3"

This flag tells moused to treat the second, or right, mouse button as if it were the third, or middle, mouse button. Now you can use the right mouse button to paste your copied text.

To apply that change, restart moused:

# /etc/rc.d/moused restart Stopping moused. Starting moused:.

Test your change by copying some text with the left mouse button and pasting with the right mouse button.

1.6.2 If X Is Not Installed

You can achieve the same results on a system without X installed. You'll have to add the lines to /etc/rc.conf manually, though.

The example I've given you is for a PS/2 mouse. If you're using another type of mouse, read the "Configuring Mouse Daemon" section of man moused. It gives explicit details on figuring out what type of mouse you have and what type of protocol it understands. It even includes a section on configuring a laptop system for multiple mice: one for when on the road and one for when the laptop is attached to the docking station.

For example, if you're using a USB mouse, the only difference is that the port is /dev/usm0 instead of /dev/psm0.

A serial mouse physically plugged into COM1 would be /dev/cuaa0. You may have to experiment with the type, as auto doesn't work with all serial mice. Again, the manpage is your best reference.

1.6.3 See Also

  • man moused

  • Documentation on enabling mouse support in NetBSD at http://www.netbsd.org/Documentation/wscons/

  • Documentation on enabling mouse support in OpenBSD at http://www.openbsd.org/faq/faq7.html)

BSD Hacks
BSD Hacks
ISBN: 0596006799
EAN: 2147483647
Year: 2006
Pages: 160
Authors: Lavigne

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net