Copy from tmux to any editor not working

tmuxvi

I am trying to copy from tmux to my browser. I followed the post

Copying between tmux buffers and the system clipboard which tells me to add

setw -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
bind y run-shell "tmux show-buffer | xclip -sel clip -i" \; display-message "Copied tmux buffer to system clipboard"

. My new ~/.tmux.conf looks like the below one :

setw -g mode-keys vi
set -g mode-mouse on
set-option -g status on
set-option -g status-interval 2
set-option -g status-utf8 on
set-option -g status-justify "centre"
set-option -g status-left-length 60
set-option -g status-right-length 90
set-option -g status-left "#(~/tmux-powerline/powerline.sh left)"
set-option -g status-right "#(~/tmux-powerline/powerline.sh right)"

set-window-option -g window-status-current-format "#[fg=colour235, bg=colour27]?#[fg=colour255, bg=colour27] #I ? #W #[fg=colour27, bg=colour235]?"
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
bind y run-shell "tmux show-buffer | xclip -sel clip -i" \; display-message "Copied tmux buffer to system clipboard"

After setup,
I tried

  1. Ctrl-b [ (before copy mode)
  2. v (copy mode)
  3. y (yank)
  4. Ctrl-b y (to move to system buffer)
  5. Goto browser and paste with Ctrl-v

Seems working upto SETP 4 as I see the message

Copied tmux buffer to system clipboard

But pasting somewhere (STEP 5) else is not working.

I am using ubuntu 12.04.

Best Answer

I have the same configuration as you and it is working.

# Use vim keybindings in copy mode
setw -g mode-keys vi
bind [ copy-mode
unbind ]
bind ] paste-buffer

bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
bind y run-shell "tmux show-buffer | xclip -sel clip -i" \; display-message "Copied tmux buffer to system clipboard"

Make sure to reload your tmux configuration file with the command:

:source-file ~/.tmux.conf

Or from the shell

tmux source-file ~/.tmux.conf

You can also make a shortcut for that :

# reload .tmux.conf 
bind-key r source-file ~/.tmux.conf \; display-message "Configuration reloaded"
Related Question