Skip to content

Instantly share code, notes, and snippets.

@will-wow
Created July 25, 2017 00:27
Show Gist options
  • Save will-wow/258eba731f43b65d8ea44d6fc537f391 to your computer and use it in GitHub Desktop.
Save will-wow/258eba731f43b65d8ea44d6fc537f391 to your computer and use it in GitHub Desktop.
Copying and Pasting with tmux 2.4+
# Unbind from non-macOS setup
unbind-key -T copy-mode-vi 'y'
# Copy now goes to macOS clipboard
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
set-window-option -g mode-keys vi
# vi-style copying
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# Import macOS-only config
if-shell 'test "$(uname -s)" = Darwin' 'source-file ~/.tmux-osx.conf'
# Old 1.8 version:
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-pipe "reattach-to-user-namespace pbcopy"
# New 2.4 version:
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode 'Enter' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
brew install reattach-to-user-namespace
set-option -g default-command "reattach-to-user-namespace -l bash"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment