copy buffer from tmux/tmuxinator ( terminal multiplexer ) to the X-Clipboard

tmux ( tmuxinator for configuration and start of a configured session )
allows to open in one terminal multiple shells and split the window and so
on.

To copy data from the shell you must scroll up most of the time.

Scrolling is done by

<bind-key> - <screen up>.

In My case <Ctrl-A><screen up>

If you want to select enter selection mode with <bind-key><[>

Pressing <SPACE> sets the start mark and <RETURN> finishes the selection.

To get the buffer from tmux into the X-clipboard I found the following hint
here:

# Copy into clipboard
bind C-c choose-buffer "run \"tmux save-buffer -b '%%' - | xclip -i -selection clipboard\""
# Paste from clipboard
bind C-v run "xsel -o -b | tmux load-buffer - && tmux paste-buffer"
# Copy into primary
bind C-y choose-buffer "run \"tmux save-buffer -b '%%' - | xsel -i\""
# Paste from primary
bind C-p run "xsel -o | tmux load-buffer - && tmux paste-buffer"
 

After adding this commands you can copy the selected buffer with
<bind-key><C-c> and the X-clipboard has the data.


Update: 
 
 After doing a C-c to copy the chosen buffer to the clipboard, the bind key of tmux 
 doesn't work anymore. After reading through a bug-message here, I had to change the 
 binding a little bit by adding -b to the run command: 
bind C-c choose-buffer "run -b \"tmux save-buffer -b '%%' - | xclip -i -selection clipboard\""

otherwise xclip is running forever blocking further tmux commands.