Reputation: 2807
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 the tmux window and paste it in the 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:
tmux.conf
?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?
Upvotes: 40
Views: 69443
Reputation: 647
On tmux 1.8 running in ssh session under Putty 0.73 on Windows, below works for me.
COPY: Use ctrl+b,] got to start line, press Spacebar (it will start selection and highlighting text), use arrow or PageUp to go to end line, press Enter to get all selected text in buffer.
PASTE: ctrl+b,]
set-window-option -g mode-keys vi
bind P paste-buffer
bind-key -T copy-mode-vi c send-keys -X copy-pipe-and-cancel "xclip -i -selection clipboard"
Upvotes: -4
Reputation: 669
Searching tmux copy clipboard
this question was shown and I'd like to share one of the ways how to deal with the problem if you're using tmux
within VSCode
. I use selection with the mouse with set -g mouse on
setting in .tmux.conf
; to get the selected fragment which is stored in tmux buffer I do cat | code -
and paste in the running cat
with Ctrl-b + ]
; pasted fragment occurs in VSCode
editor too, then it's easy to copy from the window.
Upvotes: 3
Reputation: 145
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.
Upvotes: 11
Reputation: 363
You can start by looking at the example configurations at: /usr/share/doc/tmux/examples$
You can also look at the current key bindings using ctrl+b+?.
You can change these default key bindings in the .tmux.conf file. It depends on your settings how you select a piece of text in tmux window. You can map the key bindings as per vim. Enter the copy mode (ctrl+b + [), scroll to the start/end of the text you want to copy to the tmux clipboard, press v (provided the key bindings as per vim) to start copying. move to the other end of the text, press y to yank the text. press ctrl+b+] to paste the text.
I am trying to figure out how to copy/paste from system clipboard on this version. Will update my answer if I have any luck.
Upvotes: 2