From 2226730f0ba5634909df1c11670a0ab2250842af Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.dev>
Date: Tue, 19 Nov 2024 21:31:10 +0000
Subject: [PATCH] Fix yanking from tmux to the clipboard

---
 modules/home-manager/tmux.nix | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/modules/home-manager/tmux.nix b/modules/home-manager/tmux.nix
index 8799ab68..7d39e4b4 100644
--- a/modules/home-manager/tmux.nix
+++ b/modules/home-manager/tmux.nix
@@ -42,12 +42,9 @@ in
 
       bind-key C-j choose-tree
 
-      # Use vim keybindings in copy mode
-      setw -g mode-keys vi
-
-      # Setup 'v' to begin selection as in Vim
-      bind-key -T copy-mode-vi 'v' send -X begin-selection
-      bind-key -T copy-mode-vi 'y' send -X copy-pipe wl-copy
+      set-window-option -g mode-keys vi
+      bind -T copy-mode-vi v send-keys -X begin-selection
+      bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
 
       bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"