Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy text from tmux window to system clipboard?

I am using Ubuntu 16.04 with tmux 2.1. Mostly I split the screen in two tmux windows split vertically. Frequently I need to copy long pieces of text from tmux window and paste in sublime text/browser. I have a feeling that xsel/xclip could be used to achieve the same. However, most of the how-to's floating in the Internet are severely bloated, trying to explain intricate configuration option without really explaining:

  • What exactly do I need to configure in tmux.conf?
  • How do I select a piece of text in tmux window?
  • How do I copy the selected piece of text?
  • How do I paste the text from system clipboard to text editor/browser?

I don't want to be a tmux guru. All I want to get the job done in simplest possible way. Any clue how to do that?

like image 754
Holmes.Sherlock Avatar asked Oct 28 '22 21:10

Holmes.Sherlock


1 Answers

I personally am using Ubuntu 18.04 in WSL2 . However this solution will work on Ubuntu 16.04 also.
I have been using tmux-yank for copything text from tmux buffer to system clipboard. You would first need to set up Tmux Plugin Manager. Follow this link.

Then set add tmux-yank plugin to your .tmux.conf file , see here.

like image 148
Archisman Pathak Avatar answered Oct 31 '22 11:10

Archisman Pathak