Compare commits

...

2 commits

Author SHA1 Message Date
3f82cd47a8 home: tmux: add hyperlinks support
All checks were successful
ci/woodpecker/push/check Pipeline was successful
Somewhat unfortunate that those have to be enabled by force, but easy
enough to support.
2024-03-07 15:47:23 +00:00
889c53ea16 home: tmux: migrate to 'terminalFeatures'
There are other terminal capabilities I want to override in tmux, so
let's make this type more extensible.
2024-03-07 15:47:22 +00:00
4 changed files with 37 additions and 22 deletions

View file

@ -12,8 +12,10 @@
# I use scripts that use the passthrough sequence often on this host
enablePassthrough = true;
# HTerm uses `xterm-256color` as its `$TERM`, so use that here
trueColorTerminals = [ "xterm-256color" ];
terminalFeatures = {
# HTerm uses `xterm-256color` as its `$TERM`, so use that here
xterm-256color = { };
};
};
ssh = {

View file

@ -15,8 +15,10 @@
# I use scripts that use the passthrough sequence often on this host
enablePassthrough = true;
# HTerm uses `xterm-256color` as its `$TERM`, so use that here
trueColorTerminals = [ "xterm-256color" ];
terminalFeatures = {
# HTerm uses `xterm-256color` as its `$TERM`, so use that here
xterm-256color = { };
};
};
};
}

View file

@ -8,11 +8,11 @@
};
};
# Allow using 24bit color when SSH-ing from various clients
tmux.trueColorTerminals = [
# Allow using extended features when SSH-ing from various clients
tmux.terminalFeatures = {
# My usual terminal, e.g: on laptop
"alacritty"
];
alacritty = { };
};
# Always start a tmux session when opening a shell session
zsh.launchTmux = true;

View file

@ -5,6 +5,14 @@ let
config.my.home.x.enable
(config.my.home.wm.windowManager != null)
];
mkFlags = opt: flag:
let
mkFlag = term: ''set -as terminal-features ",${term}:${flag}"'';
enabledTerminals = lib.filterAttrs (_: v: v.${opt}) cfg.terminalFeatures;
terminals = lib.attrNames enabledTerminals;
in
lib.concatMapStringsSep "\n" mkFlag terminals;
in
{
options.my.home.tmux = with lib; {
@ -12,16 +20,22 @@ in
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.
terminalFeatures = mkOption {
type = with types; attrsOf (types.submodule {
options = {
trueColor = my.mkDisableOption "24-bit (RGB) color support";
hyperlinks = my.mkDisableOption "hyperlinks through OSC8";
};
});
default = { ${config.my.home.terminal.program} = { }; };
defaultText = litteralExpression ''
{ ''${config.my.home.terminal.program} = { }; };
'';
example = [ "xterm-256color" ];
example = { xterm-256color = { }; };
description = ''
$TERM values which should be considered to always support 24-bit color.
$TERM values which should be considered to have additional features.
'';
};
};
@ -90,12 +104,9 @@ in
}
# Force 24-bit color for each relevant $TERM
${
let
mkTcFlag = term: ''set -as terminal-features ",${term}:RGB"'';
in
lib.concatMapStringsSep "\n" mkTcFlag cfg.trueColorTerminals
}
${mkFlags "trueColor" "RGB"}
# Force OSC8 hyperlinks for each relevant $TERM
${mkFlags "hyperlinks" "hyperlinks"}
'';
};
}