I'm running tmux 1.6 and I'm trying to configure it to use vi-style keybindings as well as use the system clipboard when copying in interactive mode:
set-window-option -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' "copy-selection && run \"tmux save-buffer | xclip -selection clipboard\""
Simply put, I'd like to be able to do C+[ and then use v to begin selecting text for copying, then when y is pushed, copy the selection to the tmux selection and then export it to the system clipboard using xclip.
Unfortunately, when I try to do this, I see the following:
.tmux.conf: 14: unknown command: copy-selection && run "tmux save-buffer | xclip -selection clipboard"
Is there a way to do this in tmux configuration?
xclipis actually installed in your system (it's not installed by default on Ubuntu, you need tosudo apt-get install xclipto get it) – RubenLaguna May 28 '15 at 11:26xclipwithpbcopy. For Cygwin on Windows, replace it withputclip(from thecygutils-extrapackage). – SnoringFrog Jun 17 '16 at 15:09bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"– Matthias Braun Nov 30 '17 at 19:30set -g mouse on. This is supposed to enable "mouse mode" but even after removing it everything regarding my mouse works fine (scroll wheel works, mouse selection works)... – ndemou Jun 15 '18 at 10:32
– Gurce Jan 08 '19 at 03:10bind-key -t vi-copy y copy-pipe "cat >/dev/clipboard"tmux lsandtmux kill-session -t [id]it started working. You can enter tmux command mode by doingprefix + :and there you can enter thebind -T copy-mode-vi ...command manually to see if it'll work on a fresh session at all – walnut_salami Jan 11 '20 at 12:07bindline isn't a terminal command. It belongs in the~/.tmux.conffile – AjaxLeung Jan 26 '20 at 09:14<Space>(for starting visual mode/selection) to actualvbutton(to stay consistent withvimstyle). Or is it simply impossible? – Drew Jan 07 '21 at 12:10xclip) – axolotl Oct 05 '21 at 14:38cat > ~/.cache/clipboardas one comment above suggests (but with/dev/clipboard) – axolotl Oct 05 '21 at 14:39set -s copy-command 'xclip -selection clipboard'is sufficient. Note this does not bind with Y, you don't need press y after enter. See https://github.com/tmux/tmux/wiki/Clipboard#available-tools – unifreak Jan 13 '23 at 22:46unbind enterbeforebind -T copy-mode-vi enter send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'– Wu Wei Jan 27 '23 at 23:34