From 899af4218c5a8dd6d6f98e55e21d0c7ccc6b13f7 Mon Sep 17 00:00:00 2001 From: robin Date: Fri, 1 Aug 2025 16:53:46 +0200 Subject: [PATCH] tmux: fix prefix and shortcut settings (#7549) adjusting the tmux lines for setting the prefix. previously the prefix option would be set in the prefix key table, causing it to not register correctly. - updated tests --- modules/programs/tmux.nix | 28 ++++++++----------- tests/modules/programs/tmux/prefix.conf | 2 +- .../tmux/shortcut-without-prefix.conf | 5 ++-- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix index 46df3763..e6efb103 100644 --- a/modules/programs/tmux.nix +++ b/modules/programs/tmux.nix @@ -84,23 +84,17 @@ let ''} ${ - if cfg.prefix != null then - '' - # rebind main key: ${cfg.prefix} - unbind C-${defaultShortcut} - set -g prefix ${cfg.prefix} - bind -N "Send the prefix key through to the application" \ - ${cfg.prefix} send-prefix - '' - else - optionalString (cfg.shortcut != defaultShortcut) '' - # rebind main key: C-${cfg.shortcut} - unbind C-${defaultShortcut} - set -g prefix C-${cfg.shortcut} - bind -N "Send the prefix key through to the application" \ - ${cfg.shortcut} send-prefix - bind C-${cfg.shortcut} last-window - '' + let + defaultPrefix = "C-${defaultShortcut}"; + prefix = if cfg.prefix != null then cfg.prefix else "C-${cfg.shortcut}"; + in + optionalString (prefix != defaultPrefix) '' + # rebind main key: ${prefix} + unbind ${defaultPrefix} + set -g prefix ${prefix} + bind -n -N "Send the prefix key through to the application" \ + ${prefix} send-prefix + '' } ${optionalString cfg.disableConfirmationPrompt '' diff --git a/tests/modules/programs/tmux/prefix.conf b/tests/modules/programs/tmux/prefix.conf index cf7bfcdf..eee6ff9e 100644 --- a/tests/modules/programs/tmux/prefix.conf +++ b/tests/modules/programs/tmux/prefix.conf @@ -15,7 +15,7 @@ set -g mode-keys emacs # rebind main key: C-a unbind C-b set -g prefix C-a -bind -N "Send the prefix key through to the application" \ +bind -n -N "Send the prefix key through to the application" \ C-a send-prefix diff --git a/tests/modules/programs/tmux/shortcut-without-prefix.conf b/tests/modules/programs/tmux/shortcut-without-prefix.conf index 1058c5e9..eee6ff9e 100644 --- a/tests/modules/programs/tmux/shortcut-without-prefix.conf +++ b/tests/modules/programs/tmux/shortcut-without-prefix.conf @@ -15,9 +15,8 @@ set -g mode-keys emacs # rebind main key: C-a unbind C-b set -g prefix C-a -bind -N "Send the prefix key through to the application" \ - a send-prefix -bind C-a last-window +bind -n -N "Send the prefix key through to the application" \ + C-a send-prefix