Clipper


presented by

Greg Hurrell

The problem

  • tmux knows nothing about your Mac's clipboard
  • pbcopy won't work inside tmux
  • Vim inside tmux can't write to your Mac's clipboard
  • Vim inside tmux on another host knows even less about your Mac's Clipboard

The solution

brew install clipper

Demo

Teaching tmux to talk to Clipper

# For your ~/.tmux.conf:

# tmux < 1.8: bind <prefix>-y to forward to Clipper
bind-key y run-shell "tmux save-buffer - | nc localhost 8377"

# tmux >= 1.8: bind "Enter" in copy mode to both copy and
# forward to Clipper
bind-key -t vi-copy Enter copy-pipe "nc localhost 8377"

Teaching Vim to talk to Clipper

# For your ~/.vimrc:

# Bind <leader>y to forward last-yanked text to Clipper
nnoremap <leader>y :call system('nc localhost 8377', @0)<CR>

Teaching Bash/Zsh to talk to Clipper

# For your ~/.bash_profile or ~/.zshrc:

# Pipe anything into `clip` to forward it to Clipper
alias clip="nc localhost 8377"

Teaching SSH to work with Clipper

# For your ~/.ssh/config:

# Forward Clipper connection to remote host
Host host.example.org
  RemoteForward 8377 localhost:8377

What about pasting?

  • Clipper is effectively a uni-directional channel
  • Copies but doesn't paste
  • For pasting, we rely on Xterm's "bracketed paste mode"
  • A subject for another talk, unless you want to go through my dotfiles
  • https://github.com/wincent/wincent

Metadata