27

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

2 Answers2

38

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

Eric Leschinski
  • 2,221
  • 1
  • 20
  • 24
bolzano
  • 1,570
10

You can use xclip or xsel, to install xsel just do:

sudo apt-get install xsel

and then do

pwd | xsel -b

to copy the output of pwd to the clipboard.

To get the content of the clipboard you can use:

xsel -b

Here you can read a review of xclip and xsel:

http://trembits.blogspot.com/2009/09/clipboard-from-command-line-xclip.html