copy text from tmux inside VSCode
Asked Answered
D

3

9

I use VSCode on macOS, I ssh into Linux remote station and here I run tmux (inside VSCode integrated terminal). However, I am not able to copy any text from tmux into system clipboard when used like this. I am not even able to select the text using mouse - when I select any the selection highlight disappears immediately.

The copying to system clipboard works if:

  • I run tmux inside separate window of iTerm2
  • I run normal zshell inside VSC integrated terminal

How to copy text from tmux inside VSC integrated terminal?

Dwyer answered 1/11, 2022 at 11:24 Comment(0)
D
11

Solved using the mouse while holding Alt (Option) key. This way I can copy text from Tmux inside VSCode.

EDIT: You also want to set

"terminal.integrated.macOptionClickForcesSelection": true

as @hulius suggested

Dwyer answered 23/1, 2023 at 9:17 Comment(3)
For this to work you'll need the option "terminal.integrated.macOptionClickForcesSelection": true. source: github.com/microsoft/vscode/issues/86829#issuecomment-669899881Hexateuch
@Hexateuch can you please promote your comment to an answer? I found it quite helpful and the upvotes imply others did also.Feller
@Dwyer has edited his answer to highlight that part. Thank you for the praise @studgeek!Hexateuch
N
3

There are answers mentioning how to set it up holding Alt key on Mac, but it didn't work for me on Linux.

Holding Shift instead of Alt worked out of the box though.

Noisemaker answered 9/7, 2023 at 9:2 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Mastiff
S
2

That is because vscode terminal does not support osc52. We gotta wait for this issue to be resolved https://github.com/xtermjs/xterm.js/issues/3260

OSC 52 (OSC stands for Operating System Command, a category of ANSI escape sequences which instruct the terminal emulator to perform certain actions) is a terminal sequence used to copy printed text into clipboard, without which copying from remote machine will not send the result to your local clipboard. Applications like tmux support it (actually, tmux is kinda forwarding it), iterm2 support it but not vscode

Sheepshead answered 6/1, 2023 at 2:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.