Skip to content

Commit 69a048c

Browse files
EliasA5jesseduffield
authored andcommitted
Update instructions for using OSC52 with tmux
Signed-off-by: Elias Assaf <[email protected]>
1 parent 6c6d835 commit 69a048c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

docs/Config.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,26 @@ os:
667667
Specify an external command to invoke when copying to clipboard is requested. `{{text}` will be replaced by text to be copied. Default is to copy to system clipboard.
668668

669669
If you are working on a terminal that supports OSC52, the following command will let you take advantage of it:
670+
```yaml
671+
os:
672+
copyToClipboardCmd: printf "\033]52;c;$(printf {{text}} | base64 -w 0)\a" > /dev/tty
673+
```
674+
675+
For tmux you need to wrap it with the [tmux escape sequence](https://github.com/tmux/tmux/wiki/FAQ#what-is-the-passthrough-escape-sequence-and-how-do-i-use-it), and enable passthrough in tmux config with `set -g allow-passthrough on`:
676+
```yaml
677+
os:
678+
copyToClipboardCmd: printf "\033Ptmux;\033\033]52;c;$(printf {{text}} | base64 -w 0)\a\033\\" > /dev/tty
670679
```
680+
681+
For the best of both worlds, we can let the command determine if we are running in a tmux session and send the correct sequence:
682+
```yaml
671683
os:
672-
copyToClipboardCmd: printf "\033]52;c;$(printf {{text}} | base64)\a" > /dev/tty
684+
copyToClipboardCmd: >
685+
if [[ "$TERM" =~ ^(screen|tmux) ]]; then
686+
printf "\033Ptmux;\033\033]52;c;$(printf {{text}} | base64 -w 0)\a\033\\" > /dev/tty
687+
else
688+
printf "\033]52;c;$(printf {{text}} | base64 -w 0)\a" > /dev/tty
689+
fi
673690
```
674691

675692
A custom command for reading from the clipboard can be set using

0 commit comments

Comments
 (0)