Terminal – copy from CLI without using mouse

copy/pastegnome-terminalterminal

While firing commands in CLI, I want to copy the command I just fired or anything I wrote in terminal and paste it somewhere else without using mouse.

Like in following picture, I want to copy the update command (completely or partially) without using mouse and paste it somewhere.

copy from CLI without using mouse

Best Answer

You can use screen(1) within your terminal emulator of choice (xterm, gnome-terminal, ...).

The functionality you need is built-in in screen. You need to get familiar with the way it works:

  • by default, the "command" keybinding is Ctrl + A, you compose commands by issuing the "command" sequence plus the specific action.
  • the "copy" command is: AltGr + [
  • the "paste" command is AltGr + ]

You can "copy" the command and "paste" in another terminal.

screen is fun and once you start using it you'll wonder how it is possible you haven't been using it at all.