Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I copy the output of the last executed command directly into my clipboard?

I have seen this post: how-can-i-copy-the-output-of-a-command-directly-into-my-clipboard

I have got this alias

# Redoes the last command and copies the output to clipboard

  alias cl="fc -e -|pbcopy"

However I would like an alias or a function that doesn't redo the last command, but does copy the output of the last command.

like image 445
dimitrieh Avatar asked Jan 22 '16 10:01

dimitrieh


1 Answers

Shells in common use on Linux (such as bash) do not preserve the output from the previous command, so re-execution is the only solution unless you add code to do the preservation yourself. Pbcopy isn't always installed, xclip seems more commonly installed:

    ls -l
    !! | xclip
like image 158
Michael Hamilton Avatar answered Oct 20 '22 01:10

Michael Hamilton