Copy current terminal prompt to clipboard

Solution 1:

To cut, press ctrl+u. To paste, use ctrl+y. This copies whole line to bash clipboard. If you're using X and default Ubuntu terminal, you can use your mouse to mark contents and press ctrl+shift+c to copy, and ctrl+shift+v to paste.

Solution 2:

  • Add a # to the front of the command (so it becomes a comment)
  • Run it
  • Grab it from the history and pipe it to a clipboard utillity like xclip: history | tail -n 1 | sed "s/[[:digit:]]* //" | sed "s/^#//" | xclip