Is it possible to copy a "block" of text from a terminal window without having to copy entire lines?


enter image description here

Say I just wanna copy the text I’ve circled in the image above, is this possible? Or do I also have to copy everything to the left of the block I want to copy?


You should be able to do this by holding the option key down while doing it. This changes the cursor to a '+' sign and allows you to select any rectangular area of text.

See screenshot below:

enter image description here

If you look at the above image closely, you'll see in the left window I've highlighted a block of text in Terminal and in the right window I've been able to paste this text into a new TextEdit document.

  • 4
    This doesn't work in iTerm but works fine in Terminal. – Natsfan Dec 14 '18 at 15:14

When using iTerm2, you can either use Cmd+Option+mouse to perform vertical/block selection, which transforms your cursor into a cross, similar to Terminal.app.

Or you can use copy mode:

  • Cmd+Shift+C to enter copy mode
  • Ctrl+v to enter vertical/block mode
  • Move the cursor using the cursor keys on the keyboard (see link for more movement options)
  • Once you’re done, use Ctrl+k, y to copy the selection.

You might also try using awk to limit the shell output to what you want. You could then even pipe it to pbcopy

  • 2
    Or just cut -c 56- or so. – Wildcard Dec 15 '18 at 2:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .