Why can't I paste into xterm (XQuartz)?

28

12

I'm on a Mac (OS 10.8.2) and I'd like to start using xterm as my default terminal, rather than Terminal.app. Unfortunately, I can't paste text into an xterm window, and this is something that I frequently want to do. When I try, it pastes strange characters rather than what I thought that I had in my clipboard. For example, if use the trackpad to highlight my username in the xterm command prompt (gregory) and then hit cmd+V to paste, the text <00f6> appears. If the text that I copied was from a web browser, then only ö appears (an umlauted 'o').

I have tried toggling all the settings in Pasteboard Preferences (enable syncing, update pasteboard when clipboard changes, update clipboard when pasteboard changes, update pasteboard immediately when new text is selected) and none of those settings appear to have any effect; certainly none have allowed me to paste.

The behavior that I want is the standard cmd+C to copy and cmd+V to paste, though I could accept alternative key bindings.

Can anyone here explain the behavior that I'm observing and recommend a solution?

Gregory

Posted 2012-12-11T15:08:46.660

Reputation: 453

For recent version of OSX (I use 10.12), the following works: https://stackoverflow.com/a/9525347/1353267

– Samveen – 2018-06-16T12:28:17.493

2I can’t answer your question, but here are two hints: (1) Have you checked your xterm documentation carefully?  I haven’t used xterm for several years, but I recall that it liked to use a mouse-click combination to paste, rather than a (something)+V combination.  (2) Did you notice that ö (‘o’ umlaut) is U+00F6 (Unicode character 00F6)?  Probably not a coincidence. – Scott – 2012-12-11T17:18:54.357

2It appears that the solution might involve creating a ~/.Xmodmap file, but short of figuring out out to do that without clobbering things unintentionally, I've found a word-around with the shell command pbpaste. – Gregory – 2012-12-16T11:47:18.907

Answers

33

You need to middle-click to paste the contents of the OS X Pasteboard (as the X11 settings call it.) If you don't have a middle mouse button, turn on "Emulate three button mouse" in the X11 Preferences under the "Input" tab, along with "Enable syncing" and "Update PRIMARY when Pasteboard changes" under the "Pasteboard" tab. Then you can paste whatever you copied in the rest of Mac OS X by holding down Option and clicking.

If you want to use +V, you can put this line into your .Xdefaults file:

*VT100.translations: #override  Meta <KeyPress> V:  insert-selection(PRIMARY, CUT_BUFFER0) \n

Then make sure that "Update PRIMARY when Pasteboard changes" is enabled under the "Pasteboard" tab in X11 Preferences. You may need to ensure that you don't have anything in .Xmodmap (or elsewhere) changing relevant key mappings. To apply your new settings, either quit and restart X11, or run xrdb -merge ~/.Xdefaults and then open a new xterm.

Selecting text in xterm, and hitting +C to copy, should work, if you have turned on "Enable key equivalents under X11" under the "Input" tab, and "Update Pasteboard when CLIPBOARD changes" under the "Pasteboard" tab.

Nick Matteo

Posted 2012-12-11T15:08:46.660

Reputation: 586

2Yes, I have no middle mouse button on my track pad... – Michael – 2017-07-28T18:29:50.830

1

@Michael Then go to XQuartz > Preferences > Input > Emulate three button mouse. Or you could install something like BetterTouchTool, which is a more general solution.

– GDP2 – 2017-10-24T02:58:46.690

2

do you have a 3 key mouse? press the wheel key, it will paste the content of the clipboard to the cursor location.

Lorenzo Von Matterhorn

Posted 2012-12-11T15:08:46.660

Reputation: 2 137

1

@Gregory Then go to XQuarts > Preferences > Input > Emulate three button mouse. Or you could install something like BetterTouchTool, which is a more general solution.

– GDP2 – 2017-10-24T03:00:04.123

5I don't have a mouse, as I'm using a MacBook with its trackpad. – Gregory – 2012-12-16T11:35:05.497

0

Try running xrdb -merge ~/.Xdefaults as suggested by Kundor. Unlike restarting X11, xrdb required me to agree to the Xcode license agreement on my new El Capitan OS X 10.11 install. Once that was done, my .Xdefaults file was implemented properly and ⌘+V to paste in xterm was working again.

radeachar

Posted 2012-12-11T15:08:46.660

Reputation: 1

0

If you are accessing/running this from mac terminal to connect to windows this is what made it work nicely for me

xfreerdp --no-nla --plugin cliprdr -g 1600x1000 -u "your_user_name" your_server_or_ip 

grepit

Posted 2012-12-11T15:08:46.660

Reputation: 133