Repository navigation
Copy with pbcopy on a Mac outside SSH - #11
Merged
Merged
Conversation
F2 and F9 copied only through the terminal (OSC 52), which macOS Terminal ignores: nothing reached the clipboard there. On a Mac the program runs on directly (none of SSH_CONNECTION, SSH_CLIENT, SSH_TTY set), they now go through pbcopy, which works in any terminal and confirms the copy: the status bar drops its "(OSC 52 — requires a compatible terminal)" reservation. Should pbcopy fail, the copy goes through the terminal, as elsewhere. Through SSH, pbcopy would fill the remote Mac's pasteboard, so the terminal stays the only way. pbcopy reads its input in the locale's encoding: it is run under LC_ALL=en_US.UTF-8, or anything but ASCII would arrive garbled under a locale that isn't UTF-8. TestPbcopyKeepsUnicode checks that on macOS, against the real pasteboard, whose text it puts back. The ui tests leave the pasteboard out (TestMain): on a Mac they would otherwise replace what the developer had copied, and couldn't check what goes to the terminal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
F2 (copy the result) and F9 (copy as cURL) went only through the terminal (OSC 52), which macOS Terminal ignores: nothing reached the clipboard there.
What changes
SSH_CONNECTION,SSH_CLIENT,SSH_TTYset), the copy goes throughpbcopy: it works in any terminal, macOS Terminal included, and the status bar confirms it without its "(OSC 52 — requires a compatible terminal)" reservation.pbcopyfails, the copy goes through the terminal, as before.pbcopyis never used: it would fill the remote Mac's pasteboard, not the user's.pbcopyruns underLC_ALL=en_US.UTF-8: under a locale that isn't UTF-8, anything but ASCII would arrive garbled.Tests
TestLocalPasteboard: which systems and sessions getpbcopy.TestCopyGoesToThePasteboard,TestCopyFallsBackOnTheTerminal: F2 and F9 with a fake pasteboard, and the fallback.TestPbcopyKeepsUnicode(macOS only): the realpbcopy, with accented text under a non-UTF-8 locale, read back withpbpaste; it puts the pasteboard's previous text back. The macOS job of this PR is its first run: it hasn't run anywhere else.The ui tests leave the pasteboard out (
TestMain): on a Mac they would otherwise replace what the developer had copied.🤖 Generated with Claude Code