# How to copy text from 'xterm'



## erdos (Jul 18, 2015)

hi,

I have FreeBSD installed on my laptop, with x11-wm/icewm as WM.  I couldn't figure out how to copy text from xterm(1) terminal screen.  Neither the middle mouse button or 'Ctl + C' works.


----------



## protocelt (Jul 18, 2015)

Add "XTerm*selectToClipboard: true" to your Xresources/Xdefaults file to force x11/xterm to use the standard X11 clipboard. x11/xterm doesn't use the X11 clipboard by default. Alternatively, you can start xterm with the following command: `xterm -ls -xrm 'XTerm*selectToClipboard: true'`


----------



## erdos (Jul 18, 2015)

I don't have a  Xresources/Xdefaults file in my home directory.
Should I create one?


----------



## protocelt (Jul 18, 2015)

Only if you want to customize Xterm which it seems is the case. I think Xdefaults is now deprecated in newer versions of X however it does still work.


----------



## erdos (Jul 18, 2015)

protocelt said:


> Add "XTerm*selectToClipboard: true" to your Xresources/Xdefaults file to force x11/xterm to use the standard X11 clipboard. x11/xterm doesn't use the X11 clipboard by default. Alternatively, you can start xterm with the following command: `xterm -ls -xrm 'XTerm*selectToClipboard: true'`




I tried `xterm -ls -xrm 'XTerm*selectToClipboard: true'`

Still not copying text.


----------



## protocelt (Jul 18, 2015)

It's always and still does work for me. Hmm, maybe I'm confused on what you're trying to do. Are you trying to copy text from Xterm to another application or the other way around?


----------



## erdos (Jul 18, 2015)

I'm trying to copy the name of a package from `pkg search` into the new command line instead of manually entering the long file name.

But by highlighting the file name first, middle mouse button, which usually acts as copy/paste, doesn't work for me, neither does 'cntl + c' key combination.

I can do the exact same thing on my desktop with xfce installed, but not on my laptop with IceWM.


----------



## protocelt (Jul 18, 2015)

I'm really not sure why that doesn't work, sorry. It might have something to do with x11-wm/icewm itself but I wouldn't have any ideas off hand as I've never used it before.


----------



## ljboiler (Jul 18, 2015)

I cut and paste text to/from one xterm to the same or another xterm by selecting the text with the left mouse button and then Shift-Ins to paste it at the current xterm cursor position.


----------



## erdos (Jul 19, 2015)

ljboiler said:


> I cut and paste text to/from one xterm to the same or another xterm by selecting the text with the left mouse button and then Shift-Ins to paste it at the current xterm cursor position.



This works!

I'm not sure why middle mouse button isn't working, that's the way how I use it for paste in Linux.


----------



## cpm@ (Jul 19, 2015)

erdos said:


> this works!
> 
> I'm not sure why middle mouse button isn't working, that's the way how i use it for paste in Linux.



For further clarification, take a look at the XTerm FAQ
http://invisible-island.net/xterm/xterm.faq.html#xterm_paste


----------

