While setting classpaths in the .bashrc, I was wondering if there was a way to copy the current output from the shell for pasting later into some editor. What I am trying to accomplish is as follows:

  1. Get the current file path using pwd, e.g. - /SomeFolder/java/bin
  2. Use "some" command to copy the output of pwd into the buffer instead of selecting it using the mouse and copying it.
  3. Pasting the path(/SomeFolder/java/bin) in the .bashrc.

I was thinking if there was a way to do it in a mouse free manner.

link|improve this question
feedback

3 Answers

up vote 2 down vote accepted
pwd | xsel -b

pwd | xclip -selection clipboard
link|improve this answer
Perfect! This is exactly what I needed. – sc_ray Sep 27 '11 at 15:26
1  
On Mac OSX, pbcopy and pbpaste would accomplish the same trick. – sc_ray Sep 27 '11 at 15:32
feedback

Way too easy:

pwd >> ~/.bashrc
link|improve this answer
feedback

This is usually by redirecting output of a command. pwd >> .bashrc (note the double >) redirects the output of pwd and adds it to .bashrc instead of to your screen.

You probably want: echo "export CLASSPATH=$CLASSPATH:$(pwd)" >> ~/.bashrc

link|improve this answer
2  
He probably wants that, but he has to learn to ask his questions the right way ;) – m0skit0 Sep 27 '11 at 15:10
Great! This would work but is there a way to have the output of the command buffered so that I can yank it to anywhere, .bashrc or just an empty text file? – sc_ray Sep 27 '11 at 15:12
1  
Still pwd >> anywhere_you_want. Or I didn't understand your question. – m0skit0 Sep 27 '11 at 17:37
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.