From 088d81b6b6698ac56a187063240b47c05cb17dab Mon Sep 17 00:00:00 2001 From: Berk Ozkutuk Date: Fri, 29 Dec 2023 23:47:48 +0100 Subject: [PATCH] tmux: true color support Adds True Color support based on the following gist: https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6 --- modules/programs/tmux.nix | 7 ++++ .../modules/programs/tmux/default-shell.conf | 2 ++ tests/modules/programs/tmux/default.nix | 1 + .../tmux/disable-confirmation-prompt.conf | 2 ++ .../modules/programs/tmux/mouse-enabled.conf | 2 ++ tests/modules/programs/tmux/prefix.conf | 2 ++ .../tmux/shortcut-without-prefix.conf | 2 ++ .../programs/tmux/truecolor-enabled.conf | 33 +++++++++++++++++++ .../programs/tmux/truecolor-enabled.nix | 26 +++++++++++++++ tests/modules/programs/tmux/vi-all-true.conf | 2 ++ 10 files changed, 79 insertions(+) create mode 100644 tests/modules/programs/tmux/truecolor-enabled.conf create mode 100644 tests/modules/programs/tmux/truecolor-enabled.nix diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix index b68fd8d5..2bbcc675 100644 --- a/modules/programs/tmux.nix +++ b/modules/programs/tmux.nix @@ -94,6 +94,11 @@ let bind-key -N "Kill the current pane" x kill-pane ''} + ${optionalString cfg.trueColor '' + set -g default-terminal "tmux-256color" + set -ag terminal-overrides ",xterm-256color:RGB" + ''} + set -g mouse ${boolToStr cfg.mouse} setw -g aggressive-resize ${boolToStr cfg.aggressiveResize} setw -g clock-mode-style ${if cfg.clock24 then "24" else "12"} @@ -293,6 +298,8 @@ in { tmuxinator.enable = mkEnableOption "tmuxinator"; + trueColor = mkEnableOption "true color support"; + plugins = mkOption { type = with types; listOf (either package pluginModule) // { diff --git a/tests/modules/programs/tmux/default-shell.conf b/tests/modules/programs/tmux/default-shell.conf index 8eb4e40f..abe143ac 100644 --- a/tests/modules/programs/tmux/default-shell.conf +++ b/tests/modules/programs/tmux/default-shell.conf @@ -23,6 +23,8 @@ set -g mode-keys emacs + + set -g mouse off setw -g aggressive-resize off setw -g clock-mode-style 12 diff --git a/tests/modules/programs/tmux/default.nix b/tests/modules/programs/tmux/default.nix index 979774a7..aeed65c4 100644 --- a/tests/modules/programs/tmux/default.nix +++ b/tests/modules/programs/tmux/default.nix @@ -8,4 +8,5 @@ tmux-shortcut-without-prefix = ./shortcut-without-prefix.nix; tmux-prefix = ./prefix.nix; tmux-mouse-enabled = ./mouse-enabled.nix; + tmux-truecolor-enabled = ./truecolor-enabled.nix; } diff --git a/tests/modules/programs/tmux/disable-confirmation-prompt.conf b/tests/modules/programs/tmux/disable-confirmation-prompt.conf index b4359316..d51f2796 100644 --- a/tests/modules/programs/tmux/disable-confirmation-prompt.conf +++ b/tests/modules/programs/tmux/disable-confirmation-prompt.conf @@ -23,6 +23,8 @@ bind-key -N "Kill the current window" & kill-window bind-key -N "Kill the current pane" x kill-pane + + set -g mouse off setw -g aggressive-resize off setw -g clock-mode-style 12 diff --git a/tests/modules/programs/tmux/mouse-enabled.conf b/tests/modules/programs/tmux/mouse-enabled.conf index 2069920d..f5b2d9a8 100644 --- a/tests/modules/programs/tmux/mouse-enabled.conf +++ b/tests/modules/programs/tmux/mouse-enabled.conf @@ -21,6 +21,8 @@ set -g mode-keys emacs + + set -g mouse on setw -g aggressive-resize off setw -g clock-mode-style 12 diff --git a/tests/modules/programs/tmux/prefix.conf b/tests/modules/programs/tmux/prefix.conf index 00f950e0..cd5b2a32 100644 --- a/tests/modules/programs/tmux/prefix.conf +++ b/tests/modules/programs/tmux/prefix.conf @@ -26,6 +26,8 @@ bind -N "Send the prefix key through to the application" \ + + set -g mouse off setw -g aggressive-resize off setw -g clock-mode-style 12 diff --git a/tests/modules/programs/tmux/shortcut-without-prefix.conf b/tests/modules/programs/tmux/shortcut-without-prefix.conf index 938ecfa8..a02fe115 100644 --- a/tests/modules/programs/tmux/shortcut-without-prefix.conf +++ b/tests/modules/programs/tmux/shortcut-without-prefix.conf @@ -27,6 +27,8 @@ bind C-a last-window + + set -g mouse off setw -g aggressive-resize off setw -g clock-mode-style 12 diff --git a/tests/modules/programs/tmux/truecolor-enabled.conf b/tests/modules/programs/tmux/truecolor-enabled.conf new file mode 100644 index 00000000..ac6395d9 --- /dev/null +++ b/tests/modules/programs/tmux/truecolor-enabled.conf @@ -0,0 +1,33 @@ +# ============================================= # +# Start with defaults from the Sensible plugin # +# --------------------------------------------- # +run-shell @sensible_rtp@ +# ============================================= # + +set -g default-terminal "screen" +set -g base-index 0 +setw -g pane-base-index 0 + + + + + +set -g status-keys emacs +set -g mode-keys emacs + + + + + + + +set -g default-terminal "tmux-256color" +set -ag terminal-overrides ",xterm-256color:RGB" + + +set -g mouse off +setw -g aggressive-resize off +setw -g clock-mode-style 12 +set -s escape-time 500 +set -g history-limit 2000 + diff --git a/tests/modules/programs/tmux/truecolor-enabled.nix b/tests/modules/programs/tmux/truecolor-enabled.nix new file mode 100644 index 00000000..3e1794e8 --- /dev/null +++ b/tests/modules/programs/tmux/truecolor-enabled.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.tmux = { + enable = true; + trueColor = true; + }; + + nixpkgs.overlays = [ + (self: super: { + tmuxPlugins = super.tmuxPlugins // { + sensible = super.tmuxPlugins.sensible // { rtp = "@sensible_rtp@"; }; + }; + }) + ]; + + nmt.script = '' + assertFileExists home-files/.config/tmux/tmux.conf + assertFileContent home-files/.config/tmux/tmux.conf \ + ${./truecolor-enabled.conf} + ''; + }; +} diff --git a/tests/modules/programs/tmux/vi-all-true.conf b/tests/modules/programs/tmux/vi-all-true.conf index 03bf2f5a..0700c327 100644 --- a/tests/modules/programs/tmux/vi-all-true.conf +++ b/tests/modules/programs/tmux/vi-all-true.conf @@ -23,6 +23,8 @@ set -g mode-keys vi + + set -g mouse off setw -g aggressive-resize on setw -g clock-mode-style 24