Keyboard text selection in Terminal

As noted in many of my Mac OS X Hints, I’m an avowed keyboard junkie—if there’s a way to do something by leaving my hands on the keyboard instead of reaching for the mouse, then that’s the method I’ll probably use. This is true even if the process seems a bit trickier than using the mouse; I find reaching for the mouse to be an intrusive option, and will usually only rely on it as a last resort. As such, I love all tips that let my hands stay on the keyboard, including today’s tidbit about Terminal.

In Terminal (in OS X 10.4 only), you can actually select and copy sections of text without touching the mouse. This behavior is actually documented in a Terminal menu item, but it’s somewhat hidden—I missed it completely until someone pointed it out to me.

To select and copy a region of text using the keyboard in Terminal, select Edit -> Keyboard Selection -> Start Keyboard Selection, or (much easier) press Command-Option-Return. Nothing will appear to have changed, but the arrow keys will now move the cursor away from its current row, and back up into the prior output. Move around with the arrow keys until you reach the starting point for your text selection, then press Return to enter “selection” mode. As you use the arrow keys now, you’ll see text highlight as you move around.

Move to the point at which you want your selection to end, and press Return again. When you do, the selection highlight will vanish and the cursor will return to its usual spot on the input line. However, what you didn’t see happening was the selection being copied to the clipboard. I put together a little movie to demonstrate how this works, and to show that the selection does wind up on the clipboard.

(You can also watch the full-size movie if you prefer ( 643x350, 1MB ).

This technique might seem a bit tricky at first, but I found that I quickly adjusted, and this is how I now select and copy smallish portions of Terminal’s output. I still reach for the mouse, though, when I want to copy a large section of Terminal’s buffer, as it’s faster than using the up arrow key to page back through lots of output.

Shop Tech Products at Amazon