Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Xterm users - clipboard nonsense. [solved]
New Posts  All Forums:Forum Nav:

Xterm users - clipboard nonsense. [solved]

post #1 of 3
Thread Starter 
Just wanted to share this with you guys... if you use xterm, you have no doubt been frustrated and confused with the state of the clipboard. I have been annoyed by this for years, and finally spent some time to figure it out and "fix it" once and for all. I am thrilled. thumb.gif I can't say for sure if gnome-terminal / other terminals have this problem, I believe they do, but they may supplement with some more friendly cut/copy/paste menus or shortcuts. Good for them. xterm is still the best

A little background info:

There's basically two clipboards.. rolleyes.gif PRIMARY, and CLIPBOARD. Xterm copies/pastes text to/from PRIMARY. Your favorite web browser copies/pastes text to/from CLIPBOARD. rolleyes.gif

Two scenarios where this is a hassle:

1) Copying text out of xterm, to paste into a GUI application. Selecting or middle mouse or ctrl+insert in xterm puts the text into the PRIMARY. Then you go to paste, and ctrl+v gets the contents from CLIPBOARD, which is different text. If you don't select anything inadvertently, middle mouse will paste, but often includes a newline at the end, which can make the receiveing application react incorrectly. I've been able to at least live with this one...

2) Copying text out of a GUI application, to paste into xterm. If you just select the text, it can be pasted ok using middle mouse or shift+insert. However, Ctrl+C in the GUI puts text on the CLIPBOARD. And most importantly, some use cases will only copy to CLIPBOARD, e.g. "right click -> copy link address". mad.gif There is no way by default to paste the contents of CLIPBOARD into xterm. shift+insert or middle mouse is only pointing to PRIMARY, which is different. You're stuck, use another app and save it to a temp file.... ridiculousness rolleyes.gif


So, the solution to this is some wacky arguments to xterm. We are going to tell xterm that any copying that occurs will get placed into the PRIMARY and CLIPBOARD buffers. And also, if we do any pasting, it should come from the CLIPBOARD. I've been testing this out and it works awesome, I can't see any gaps.

You can place these arguments into ~/.Xresources if you want, see the link below for how that can be done. I however just put it into my xterm wrapper script i already had
Code:
$ cat bin/xt
#!/bin/bash
xterm -rv -xrm 'XTerm*VT100.Translations: #override \n\ <Btn1Up>: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0) \n\ Shift <KeyPress> Insert: insert-selection(CLIPBOARD) \n\ <KeyPress> Insert: insert-selection(PRIMARY)' -e "screen" &

The -xrm argument and the string after is what makes it happen. I am also setting some colors and setting up gnu screen in the terminal, you can ignore that (although I may talk about screen in another thread, very useful).

A big thanks to this link for the info http://blog.bigsmoke.us/2010/01/31/xterm-clipboard-selection (although his arguments did not work for my particular version, had to add the <KeyPress> things)
Edited by lloyd mcclendon - 3/7/12 at 9:27pm
stable again
(25 items)
 
  
CPUCPUMotherboardGraphics
E5-2687W E5-2687W ASUS Z9PED8-WS EVGA GTX 570 (Linux host) 
GraphicsRAMHard DriveHard Drive
EVGA GTX 970 FTW (win7 guest) 64GB G.SKILL 2133 2x Crucial M4 256GB raid1 4x 3TB raid 10 
CoolingCoolingCoolingCooling
2x Apogee HD  2x RX 480 2x MCP 655 RP-452x2 rev2 (new) 
CoolingCoolingOSOS
16x Cougar Turbine CFT12SB4 (new) EK FC 580 Gentoo (host) Gentoo (x23 guests) 
OSMonitorMonitorPower
windows 7 (guest w/ vfio-pci) Viewsonic 23" 1080P Viewsonic 19" Antec HCP Platinum 1000 (new) 
CaseOtherOther
Case Labs TH10 (still the best ever) 2x Lamptron FC-5 IOGEAR 2 way DVI KVM Switch 
  hide details  
Reply
stable again
(25 items)
 
  
CPUCPUMotherboardGraphics
E5-2687W E5-2687W ASUS Z9PED8-WS EVGA GTX 570 (Linux host) 
GraphicsRAMHard DriveHard Drive
EVGA GTX 970 FTW (win7 guest) 64GB G.SKILL 2133 2x Crucial M4 256GB raid1 4x 3TB raid 10 
CoolingCoolingCoolingCooling
2x Apogee HD  2x RX 480 2x MCP 655 RP-452x2 rev2 (new) 
CoolingCoolingOSOS
16x Cougar Turbine CFT12SB4 (new) EK FC 580 Gentoo (host) Gentoo (x23 guests) 
OSMonitorMonitorPower
windows 7 (guest w/ vfio-pci) Viewsonic 23" 1080P Viewsonic 19" Antec HCP Platinum 1000 (new) 
CaseOtherOther
Case Labs TH10 (still the best ever) 2x Lamptron FC-5 IOGEAR 2 way DVI KVM Switch 
  hide details  
Reply
post #2 of 3
that is the main reason why i avoid using xterm. i will be trying this out at work tomorrow. +rep
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
post #3 of 3
It's easy in Konsole: [ctrl]+[shift]+[c] -> [ctrl]+[shift]+[v]

Or I used tmux (window manager for terminal sessions):

http://jasonwryan.com/post/6279048610/tmux-copy
more cool walkthroughs:
http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Xterm users - clipboard nonsense. [solved]