Ubuntu – copy to clipboard current path from console with no mouse

bashclipboardcommand line

I'm wondering if it possible to copy to clipboard output of pwd command.

I often need to copy some path and I have to select it with mouse, do several clicks and that is annoying for me.

What I want is piping output of pwd command to something that will copy it to clipboard so I do not have to touch my mouse

Edit: it will be great if it is possible with some built-in

Best Answer

You can use a program called xclip. For installing it type:

sudo apt-get install xclip

and then do

pwd | xclip -- which copies output of pwd to xclip

Now to get the output type:

xclip -o

or to copy to the "standard" clipboard (to avoid having to use xclip -o)

pwd | xclip -selection clipboard

for more options use

man xclip