5

Often I like to copy output from the terminal into the clipboard.

Currently I'm using the mouse. Select the text so that it is marked. Then "command" plus "c".

In a text-editor or text-processing software you can use the "shift" key (keep it pushed) together with the arrow keys for selecting text. So one needs the mouse less and can keep the hands on the keyboard.

On the terminal that doesn't work. Keeping the "shift" key pushed and pushing the arrow keys just creates this: ;2C;2B;2A;2D;2D;2D;2D;2D

Hexadecimal numbers obviously. Does anyone knows the meaning?

But my actual question is:

Can one select terminal output via keyboard?

Similar to what I have described concerning text-editors.

  • I'm not aware of any way to select a particular piece of output from Terminal, but shift+cmd+up will select all output of the previous command. – nloveladyallen Aug 18 '16 at 16:42
  • 1
    This doesn't answer your question directly, but you can copy the output of a command to the clipboard by doing somecommand | pbcopy. – leekaiinthesky Aug 18 '16 at 17:21
  • Also, if you use something like screen or iTerm2, there are ways to select text using the keyboard (perhaps not faster than using the mouse though). – leekaiinthesky Aug 18 '16 at 17:25
  • @leekaiinthesky : Thanks a lot. :) That's indeed very handy too know ... – mizech Aug 19 '16 at 5:42
3

The terminal multiplexing program tmux has configurable keyboard commands for selecting text for the purpose of copying and pasting. tmux is a very powerful addition to any terminal. It has a high learning curve, but if all you want to do is copy and paste you can learn how in a matter of moments and it will stay completely out of your way until you are ready to take the next step. tmux can be installed directly, or using a package manager such as Macports or Homebrew.

You must log in to answer this question.

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