Posts Tagged ‘tips’

~/.bashrc Perl Module Version Tip

Friday, January 9th, 2009

I often need to quickly check the version of a perl module currently installed. A while back I got tired of running:

[michael@orion(~/)] perl -MPOE::Filter -e 'print $POE::Filter::VERSION, "\n"'
1.2357

So I added a quick function to .bashrc:

pm-vers () {
    perl -M$1 -e "print \$$1::VERSION, \"\n\""
}

Now I just run:

[michael@orion(~/)] pm-vers POE::Filter
1.2357

screen copy mode can be used to copy/paste

Thursday, July 10th, 2008

I’m aware of many people that use GNU Screen’s copy mode to scroll back through terminal history but don’t actually use copy mode for copying text for later pasting. I was one of those people myself for some time. Screen supports some pretty nifty copy/paste tricks but a few basic key strokes will get you started.

Entering Copy Mode and Scrolling

By default, enter copy mode with

CTRL+a

then

ESCAPE

. You can use vi like commands to navigate through the scollback buffer. The arrows and

PAGE UP/DOWN

should work as well. A few useful commands some may be unfamiliar with:

  • M

    - jumps to the middle visible line

  • NN%

    - jumps to the specified percentage in the buffer (0 – start, 100 – end

  • g

    - jumps to the beginning of the buffer

  • G

    - jumps to the end of the buffer

These keys are even useful when you aren’t using copy mode to copy/paste text.

Copying Text

Once the cursor is at the beginning location, press

SPACEBAR

to set your first mark. Next navigate to the ending position and hit it again. The second

SPACEBAR

will set your end mark and exit copy mode. One neat and often useful feature is selecting a rectangle on the screen rather than full lines. Use

c

and

C

to set the left and right column margins to the cursor’s current location.

Pasting

Pasting is easy, just hit

CTRL+a

to activate screen then

]

to paste.

There’s More!

There are loads more options such as multiple copy buffers, the ability to append marked text to the buffer rather than replacing it, etc. Check out the man page for more screen goodness.

Rotate through Screen Windows

Thursday, June 26th, 2008

A new command in screen version 4.00 is the

idle

command.

idle time command

Executes screen command,

command

when idle for

time

seconds. E.g. to rotate through screen windows with a 3 second interval:

idle 3 next

To cancel,

idle 0