Skip to content

Commit fa45269

Browse files
committed
Update instructions for using OSC52 with tmux
Signed-off-by: Elias Assaf <[email protected]>
1 parent eef70db commit fa45269

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/Config.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,27 @@ os:
619619
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.
620620

621621
If you are working on a terminal that supports OSC52, the following command will let you take advantage of it:
622+
```yaml
623+
os:
624+
copyToClipboardCmd: printf "\033]52;c;$(printf {{text}} | base64 -w 0)\a" > /dev/tty
622625
```
626+
627+
For tmux you need to wrap it with [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`:
628+
```yaml
623629
os:
624-
copyToClipboardCmd: printf "\033]52;c;$(printf {{text}} | base64)\a" > /dev/tty
630+
copyToClipboardCmd: printf "\033Ptmux;\033\033]52;c;$(printf {{text}} | base64 -w 0)\a\033\\" > /dev/tty
625631
```
626632

633+
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:
634+
```yaml
635+
os:
636+
copyToClipboardCmd: >
637+
if [[ "$TERM" =~ ^(screen|tmux) ]]; then
638+
printf "\033Ptmux;\033\033]52;c;$(printf {{text}} | base64 -w 0)\a\033\\" > /dev/tty
639+
else
640+
printf "\033]52;c;$(printf {{text}} | base64 -w 0)\a" > /dev/tty
641+
fi
642+
```
627643

628644
## Configuring File Editing
629645

0 commit comments

Comments
 (0)