6

I use tmux + zsh in alacritty on MacOS. When I'm switching tmux to copy-mode, selecting a big portion of text and pressing y, this text isn't in my buffer and I can't paste it. But in iTerm it works. Here is my tmux.conf:

setw -g mode-keys vi
set -g default-terminal screen-256color

# bind y key in copy mode to select and copy to system clipboard
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and- 
cancel "reattach-to-user-namespace pbcopy"

# bind ctrl+v to paste in tmux
bind-key -n C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; 
tmux paste-buffer"

# smart pane switching with awareness of vim splits
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# reload config file (change file location to your the tmux.conf you 
want to use)
bind r source-file ~/.tmux.conf

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-sessionist'
set -g @plugin 'tmux-plugins/tmux-yank'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin '[email protected]/user/plugin'
# set -g @plugin '[email protected]/user/plugin'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'

2 Answers 2

4

I think alacritty has a length limit on using OSC 52 to set the clipboard but since you are using tmux-yank you can just tell tmux not to use it with set -g set-clipboard off. You shouldn't use both anyway because they will race and cause problems.

1
  • I tried this on Mac+tmux+alacritty as well, but get this whenever I try and paste bracketed-paste-magic:zle:41: not enough arguments for -U
    – Brad Parks
    Jan 7, 2020 at 12:25
0

Here's what worked for me on Mac/Alacritty/Tmux in 2022:

setw -g mode-keys vi
set -g set-clipboard off
bind-key -T copy-mode-vi v send-keys -X begin-selection
# bind y key in copy mode to select and copy to system clipboard
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"

I.e., the reattach-to-user-namespace was breaking it for me

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .