Skip to content

add useOSC52Copy (experimental) setting #19086

@lesteral

Description

@lesteral

What would you like to be added?

There currently exists a setting useOSC52Paste,
but this isn't used in copyToClipboard.
Instead, copyToClipboard uses a local test shouldUseOsc52(tty), which is heuristic in nature.
I believe that a setting, e.g., useOSC52Copy would be useful as an explicit control.

Why is this needed?

I use Gemini CLI in an Emacs terminal eat Emulate A Terminal, in a region, in a buffer and in Eshell (documentation: https://elpa.nongnu.org/nongnu/eat.html).
This works fine with Gemini CLI, except that the /copy command hangs up the eat terminal, when copyToClipboard uses the default clipboardy tool to copy.
However, if I "trick" copyToClipboard to instead use the code for which shouldUseOsc52(tty) is true, then the /copy command works reliably.
The "trick" I'm using is to define the environment variable WSL_INTEROP, so that isWSL is true, resulting in shouldUseOsc52 also true.

Excerpt from https://github.com/google-gemini/gemini-cli/blob/main/packages/cli/src/ui/utils/commandUtils.ts#L148C1-L162C1 for reference:

const isWSL = (): boolean =>
  Boolean(
    process.env['WSL_DISTRO_NAME'] ||
      process.env['WSLENV'] ||
      process.env['WSL_INTEROP'],
  );
...
const shouldUseOsc52 = (tty: TtyTarget): boolean =>
  Boolean(tty) && !isDumbTerm() && (isSSH() || isWSL() || isWindowsTerminal());

Additional context

My Gemini CLI version is 0.29.0-preview.3.

I'm using Emacs 31.0.50 (recently built version) on a Chromebook Linux (Debian 12).

I do have wl-copy installed, but I haven't so far confirmed that it's being invoked by clipboardy,
and I don't know exactly how the hangup occurs w/ /copy + clipboardy.

But I am able to use Gemini CLI /copy successfully if I bypass clipboardy entirely,
and I believe that it would be helpful to have a direct method, e.g., a useOSC52Copy (experimental) setting, to bypass clipboardy.

(My trick of defining the environment variable WSL_INTEROP works for me, but it is obviously an indirect method/hack.)

Metadata

Metadata

Assignees

Labels

area/coreIssues related to User Interface, OS Support, Core Functionalityhelp wantedWe will accept PRs from all issues marked as "help wanted". Thanks for your support!priority/p2Important but can be addressed in a future release.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions