terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Line breaks are ignored inconsistently when copying text in tmux copy mode

Open antoineco opened this issue 3 years ago • 10 comments

Environment

Windows build number: 10.0.19042.746 Windows Terminal version: 1.6.10272.0 (current Preview version from Microsoft Store)

Ubuntu WSL distribution from the Microsoft Store: 2004.2020.812.0 tmux: 3.0a (from Ubuntu's APT package repo)

Steps to reproduce

1. Open a WSL terminal

2. Run a new tmux session:

$ tmux

3. Generate some output. Here a sample output from the command I ran while running into this, for your convenience

$ cat <<EOF
Install Kubernetes apps from helm charts or YAML files using the "install"
command.

You can also find the post-install message for each app with the "info"
command.

Usage:
  arkade install [flags]
  arkade install [command]

Aliases:
  install, i

Examples:
  arkade install
  arkade install openfaas  --gateways=2
  arkade install inlets-operator --token-file $HOME/do-token
EOF

4. Press Enter multiple times, until the output disappears from the current window.

5. Enter tmux's copy mode with Ctrl-B [

Note: first Ctrl-B, then [. Not simultaneously

6. Scroll up with arrow keys or PgUp

7. Copy the previously generated output.

8. (optional) Press q to exit tmux's copy mode.

image

Expected behavior

The copied text contains line breaks at the end of each line.

In this case, I'm expecting:

You can also find the post-install message for each app with the "info"
command.

Usage:
  arkade install [flags]
  arkade install [command]

Aliases:
  install, i

Actual behavior

This is the raw pasted text. Notice the spaces before "Aliases" instead of the new line (I can replicate the issue with any text, not only that one):

You can also find the post-install message for each app with the "info"
command.

Usage:
  arkade install [flags]
  arkade install [command]
                                                                                                                                                            Aliases:
  install, i

ℹ️ Important note: this happens only in tmux's copy mode. After pressing q, copying the same output will work as expected.

antoineco avatar Jan 31 '21 12:01 antoineco