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

47,948

Solution 1

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.

Solution 2

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

Share:
47,948

Related videos on Youtube

Gregory
Author by

Gregory

Updated on September 18, 2022

Comments

  • Gregory
    Gregory over 1 year

    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?

    • Admin
      Admin over 11 years
      I 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.
    • Admin
      Admin over 11 years
      It 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.
    • Admin
      Admin almost 6 years
      For recent version of OSX (I use 10.12), the following works: stackoverflow.com/a/9525347/1353267
  • Gregory
    Gregory over 11 years
    I don't have a mouse, as I'm using a MacBook with its trackpad.
  • Michael
    Michael almost 7 years
    Yes, I have no middle mouse button on my track pad...
  • GDP2
    GDP2 over 6 years
    @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
    GDP2 over 6 years
    @Gregory Then go to XQuarts > Preferences > Input > Emulate three button mouse. Or you could install something like BetterTouchTool, which is a more general solution.