I set up tmux in WSL and I want to improve the integration between them.

How to select text in tmux inside of WSL and copy it to the Windows clipboard?

  • open the file ~/.tmux.conf and create it if it does not exist
  • enable mouse mode by adding the line set -g mouse on (if not, you will have to select the text with Ctl+[)
  • create a key binding to copy the tmux buffer to the windows clipboard:

    bind -n M-w run -b "tmux show-buffer | clip.exe"

With this key configuration, you can select text with the mouse and copy it(to the tmux buffer) using Alt+w. (If you want to select something and don't want it to disappear, press shift while letting the mouse button go.) After this, press Alt+w again in order to copy the tmux buffer to the Windows clipboard.


Alternatively, if you are using windows terminal, selecting text with the mouse while holding shift and copying it with Ctl + Insert will always just work (even through ssh) and doesn't mess up line breaks.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.