Skip to content

Conversation

@zonuexe
Copy link
Contributor

@zonuexe zonuexe commented Jan 10, 2026

This PR introduces a new copy command to PsySH, allowing users to copy the inspected value of an expression or the last evaluated result ($_) directly to the system clipboard. This feature is inspired by the clipboard integration recently implemented in Ruby's IRB (ruby/irb#1044).

To ensure a seamless experience across various environments, the command automatically detects and utilizes available clipboard backends, including:

  • pbcopy (macOS)
  • wl-copy (Wayland / WSLg)
  • xclip / xsel (X11)
  • clip.exe (Windows / WSL)

Furthermore, I have implemented support for the OSC 52 escape sequence to facilitate remote development over SSH. This allows PsySH to bridge the remote server's output to the local machine's clipboard. OSC 52 is increasingly adopted by modern terminal emulators, including Windows Terminal and Ghostty, both of which prioritize security while enabling this functionality.

Since OSC 52 enables a remote process to write to the local terminal, this functionality is strictly opt-in via the new useOsc52Clipboard configuration. This approach mirrors the security-conscious defaults of terminals like Ghostty, where clipboard access must be explicitly allowed. When the command is used in an SSH environment without this setting enabled, PsySH will display a helpful "Productivity Tip" on how to enable it, along with a clear security warning regarding the risks of clipboard hijacking.

スクリーンショット 2026-01-10 11 10 18

@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

❌ Patch coverage is 19.10112% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.06%. Comparing base (6bd1bfd) to head (5199b2f).

Files with missing lines Patch % Lines
src/Clipboard/ClipboardFactory.php 0.00% 19 Missing ⚠️
src/Clipboard/NullClipboardMethod.php 0.00% 17 Missing ⚠️
src/Command/CopyCommand.php 48.27% 15 Missing ⚠️
src/Clipboard/CommandClipboardMethod.php 0.00% 10 Missing ⚠️
src/Clipboard/Osc52ClipboardMethod.php 0.00% 7 Missing ⚠️
src/Configuration.php 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #910      +/-   ##
============================================
- Coverage     70.63%   70.06%   -0.57%     
- Complexity     3363     3394      +31     
============================================
  Files           157      162       +5     
  Lines          7966     8055      +89     
============================================
+ Hits           5627     5644      +17     
- Misses         2339     2411      +72     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zonuexe zonuexe force-pushed the feature/copy-command branch from c98d52c to 77fc552 Compare January 10, 2026 03:33
@zonuexe zonuexe force-pushed the feature/copy-command branch from 3ee136d to 5199b2f Compare January 11, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant