(Bug with POC workaround) use pbcopy on MacOS for better clipboard manager support #19
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.
This could be considered as a bug report with a proof of concept for a workaround.
TLDR: on Mac OS, gitk's "copy commit reference" and other clipboard operations are not detected properly by clipboard managers due to a Tk bug. The first copy from gitk is often detected, but any further ones are not.
See the links below for more details.
The POC fix is simply to shell out to Mac OS's
pbcopy
instead of using Tk'sclipboard append
on Mac OS. If the Tk bug could be fixed, that would probably be better.I am not sure whether this is ready to merge. In particular, I am not familiar with Tcl/Tk conventions and I have only tested this on Tk 8.6.16.
On Mac OS, current versions of Tk 9 or Tk 8
clipboard append
do not interact properly with clipboard managers. This makesgitk
interact badly with them as well. See 1 for an example of how this affectsgitk
and 2 for a ticket describing the problem with Tk.This commit works around the problem by having
gitk
use thepbcopy
CLI to copy to the clipboard instead of Tk'sclipboard append
, as long as we are on Mac OS andpbcopy
is available. AFAIK,pbcopy
is always installed with Mac OS.1: p0deje/Maccy#1100
2: https://core.tcl-lang.org/tk/tktview/e94c8bc845b4d5a658cd5421ef23ef2484560fa8