Compare commits

...

3 commits

Author SHA1 Message Date
42ab12179e hosts: homes: mousqueton: use 'trueColorTerminals'
All checks were successful
ci/woodpecker/push/check Pipeline was successful
Ah, much better with an actual option for this :-).
2023-10-26 19:39:44 +01:00
3a1ccea142 home: tmux: add 'trueColorTerminals'
This uses the recommended way of enabling true-color [1].

[1]: https://github.com/tmux/tmux/wiki/FAQ#how-do-i-use-rgb-colour
2023-10-26 19:37:04 +01:00
c01f657e8d lib: lists: add 'nullableToList' 2023-10-26 19:36:32 +01:00
3 changed files with 29 additions and 4 deletions

View file

@ -11,6 +11,19 @@ in
enable = my.mkDisableOption "tmux terminal multiplexer";
enablePassthrough = mkEnableOption "tmux DCS passthrough sequence";
trueColorTerminals = mkOption {
type = with types; listOf str;
default = lib.my.nullableToList config.my.home.terminal.program;
defaultText = ''
`[ config.my.home.terminal.program ]` if it is non-null, otherwise an
empty list.
'';
example = [ "xterm-256color" ];
description = ''
$TERM values which should be considered to always support 24-bit color.
'';
};
};
config.programs.tmux = lib.mkIf cfg.enable {
@ -75,6 +88,14 @@ in
set -g allow-passthrough on
''
}
# Force 24-bit color for each relevant $TERM
${
let
mkTcFlag = term: ''set -as terminal-features ",${term}:RGB"'';
in
lib.concatMapStringsSep "\n" mkTcFlag cfg.trueColorTerminals
}
'';
};
}

View file

@ -20,8 +20,6 @@
# I use scripts that use the passthrough sequence often on this host
my.home.tmux.enablePassthrough = true;
programs.tmux.extraConfig = ''
# Setup 24-bit color explicitly, as the default terminfo entry does not
set-option -sa terminal-overrides ",xterm-256color:Tc"
'';
# HTerm uses `xterm-256color` as its `$TERM`, so use that here
my.home.tmux.trueColorTerminals = [ "xterm-256color" ];
}

View file

@ -24,4 +24,10 @@ in
# (any -> value)
# [ any ]
mapFilter = pred: f: attrs: filter pred (map f attrs);
# Transform a nullable value into a list of zero/one element.
#
# nullableToList ::
# (nullable a) -> [ a ]
nullableToList = x: if x != null then [ x ] else [ ];
}