From 8d4bbaf8863e53468b4f4d8c394e826a33689b56 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 8 Feb 2022 17:23:57 +0100 Subject: [PATCH] home: tmux: fix yanking configuration Use `tmux-yank` when a GUI is enabled, otherwise use the internal tmux buffer. In both cases, stay in copy mode after yanking. --- home/tmux/default.nix | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/home/tmux/default.nix b/home/tmux/default.nix index ac2e1d2..f9b711c 100644 --- a/home/tmux/default.nix +++ b/home/tmux/default.nix @@ -1,6 +1,7 @@ { config, lib, pkgs, ... }: let cfg = config.my.home.tmux; + hasGUI = config.my.home.x.enable || (config.my.home.wm != null); in { options.my.home.tmux = with lib.my; { @@ -23,8 +24,16 @@ in pain-control # Better session management sessionist - # X clipboard integration - yank + (lib.optionalAttrs hasGUI { + # X clipboard integration + plugin = yank; + extraConfig = '' + # Use 'clipboard' because of misbehaving apps (e.g: firefox) + set -g @yank_selection_mouse 'clipboard' + # Stay in copy mode after yanking + set -g @yank_action 'copy-pipe' + ''; + }) { # Show when prefix has been pressed plugin = prefix-highlight; @@ -41,7 +50,11 @@ in extraConfig = '' # Better vim mode bind-key -T copy-mode-vi 'v' send -X begin-selection - bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel + ${ + lib.optionalString + (!hasGUI) + "bind-key -T copy-mode-vi 'y' send -X copy-selection" + } # Block selection in vim mode bind-key -Tcopy-mode-vi 'C-v' send -X begin-selection \; send -X rectangle-toggle '';