From a96044b06d879b826fc4f80019b8fa729c1e7aff Mon Sep 17 00:00:00 2001 From: Han Li Date: Wed, 2 Sep 2026 16:54:50 -0400 Subject: [PATCH] fix(tmux): copy yank to Wayland system clipboard oh-my-tmux's copy_to_os_clipboard only knows xsel/xclip, which are not present on this Ubuntu Wayland setup. Pipe copy-mode yanks through wl-copy. --- .tmux.conf.local | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.tmux.conf.local b/.tmux.conf.local index b0a184c..250315f 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -267,8 +267,9 @@ tmux_conf_theme_clock_style='24' # - true # - false (default) # on macOS, this requires installing reattach-to-user-namespace, see README.md -# on Linux, this requires xsel or xclip -tmux_conf_copy_to_os_clipboard=false +# on Linux/X11, this requires xsel or xclip +# on Wayland, oh-my-tmux does not know wl-copy — see bindings below +tmux_conf_copy_to_os_clipboard=true # -- user customizations ------------------------------------------------------- @@ -295,3 +296,14 @@ set -g mode-keys vi # move status line to top #set -g status-position top +# Wayland clipboard: this gpakosz/.tmux only pipes yanks to pbcopy/xsel/xclip. +# Ubuntu session is Wayland (wl-copy is installed; xsel/xclip are not), so copy +# mode would stay in the tmux buffer. Neovim works because it talks to wl-copy +# (or OSC 52) itself. +if-shell -b 'command -v wl-copy >/dev/null 2>&1' { + bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'wl-copy' + bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'wl-copy' + bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'wl-copy' + bind-key y run-shell -b 'tmux save-buffer - | wl-copy' +} +