mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-04 23:37:41 +02:00
Update instructions for using OSC52 with tmux (#3597)
- **PR Description** Update the instructions on using copyToClipboardCmd config to copy using OSC52 with tmux Added `-w 0` flag to `base64` command because it wraps lines that are longer than 76 by default, [that fails to copy on some terminal emulators](https://github.com/jesseduffield/lazygit/issues/3595). We compare `$TERM` to `^(screen|tmux)` because both of them are valid as [per the manual](https://man7.org/linux/man-pages/man1/tmux.1.html): ``` default-terminal terminal Set the default terminal for new windows created in this session - the default value of the TERM environment variable. For to work correctly, this must be set to ‘screen’, ‘tmux’ or a derivative of them. ``` - **Please check if the PR fulfills these requirements** * [x] Cheatsheets are up-to-date (run `go generate ./...`) -- not relevant * [x] Code has been formatted (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting)) -- not relevant * [x] Tests have been added/updated (see [here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md) for the integration test guide) -- not relevant * [x] Text is internationalised (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation)) -- not relevant * [x] Docs have been updated if necessary * [x] You've read through your own file changes for silly mistakes etc <!-- Be sure to name your PR with an imperative e.g. 'Add worktrees view' see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for examples -->
This commit is contained in:
commit
fc69945a80
@ -667,9 +667,26 @@ os:
|
||||
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.
|
||||
|
||||
If you are working on a terminal that supports OSC52, the following command will let you take advantage of it:
|
||||
```
|
||||
```yaml
|
||||
os:
|
||||
copyToClipboardCmd: printf "\033]52;c;$(printf {{text}} | base64)\a" > /dev/tty
|
||||
copyToClipboardCmd: printf "\033]52;c;$(printf {{text}} | base64 -w 0)\a" > /dev/tty
|
||||
```
|
||||
|
||||
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`:
|
||||
```yaml
|
||||
os:
|
||||
copyToClipboardCmd: printf "\033Ptmux;\033\033]52;c;$(printf {{text}} | base64 -w 0)\a\033\\" > /dev/tty
|
||||
```
|
||||
|
||||
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:
|
||||
```yaml
|
||||
os:
|
||||
copyToClipboardCmd: >
|
||||
if [[ "$TERM" =~ ^(screen|tmux) ]]; then
|
||||
printf "\033Ptmux;\033\033]52;c;$(printf {{text}} | base64 -w 0)\a\033\\" > /dev/tty
|
||||
else
|
||||
printf "\033]52;c;$(printf {{text}} | base64 -w 0)\a" > /dev/tty
|
||||
fi
|
||||
```
|
||||
|
||||
A custom command for reading from the clipboard can be set using
|
||||
|
Loading…
x
Reference in New Issue
Block a user