2021-03-13 01:02:34 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.home.tmux;
|
2023-02-20 12:06:34 +01:00
|
|
|
hasGUI = lib.any lib.id [
|
|
|
|
config.my.home.x.enable
|
|
|
|
(config.my.home.wm.windowManager != null)
|
|
|
|
];
|
2024-03-07 16:42:58 +01:00
|
|
|
|
|
|
|
mkTerminalFlags = 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;
|
2021-03-13 01:02:34 +01:00
|
|
|
in
|
2021-02-20 15:34:33 +01:00
|
|
|
{
|
2023-03-16 17:39:13 +01:00
|
|
|
options.my.home.tmux = with lib; {
|
|
|
|
enable = my.mkDisableOption "tmux terminal multiplexer";
|
2023-03-16 16:45:15 +01:00
|
|
|
|
2023-08-11 15:02:20 +02:00
|
|
|
enablePassthrough = mkEnableOption "tmux DCS passthrough sequence";
|
2023-10-26 20:37:04 +02:00
|
|
|
|
2024-03-07 16:42:58 +01:00
|
|
|
terminalFeatures = mkOption {
|
|
|
|
type = with types; attrsOf (submodule {
|
|
|
|
options = {
|
2024-03-07 16:44:17 +01:00
|
|
|
hyperlinks = my.mkDisableOption "hyperlinks through OSC8";
|
|
|
|
|
2024-03-07 16:42:58 +01:00
|
|
|
trueColor = my.mkDisableOption "24-bit (RGB) color support";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
default = { ${config.my.home.terminal.program} = { }; };
|
|
|
|
defaultText = litteralExpression ''
|
|
|
|
{ ''${config.my.home.terminal.program} = { }; };
|
2023-10-26 20:37:04 +02:00
|
|
|
'';
|
2024-03-07 16:42:58 +01:00
|
|
|
example = { xterm-256color = { }; };
|
2023-10-26 20:37:04 +02:00
|
|
|
description = ''
|
2024-03-07 16:42:58 +01:00
|
|
|
$TERM values which should be considered to have additional features.
|
2023-10-26 20:37:04 +02:00
|
|
|
'';
|
|
|
|
};
|
2021-03-13 01:02:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config.programs.tmux = lib.mkIf cfg.enable {
|
2021-02-20 15:34:33 +01:00
|
|
|
enable = true;
|
|
|
|
|
2021-03-27 16:44:27 +01:00
|
|
|
keyMode = "vi"; # Home-row keys and other niceties
|
2021-02-20 15:34:33 +01:00
|
|
|
clock24 = true; # I'm one of those heathens
|
|
|
|
escapeTime = 0; # Let vim do its thing instead
|
2024-03-08 13:56:19 +01:00
|
|
|
historyLimit = 100000; # Bigger buffer
|
2021-02-20 15:51:54 +01:00
|
|
|
terminal = "tmux-256color"; # I want accurate termcap info
|
2021-02-20 15:37:39 +01:00
|
|
|
|
|
|
|
plugins = with pkgs.tmuxPlugins; [
|
|
|
|
# Open high-lighted files in copy mode
|
|
|
|
open
|
|
|
|
# Better pane management
|
|
|
|
pain-control
|
|
|
|
# Better session management
|
|
|
|
sessionist
|
2023-02-20 12:10:35 +01:00
|
|
|
{
|
2022-02-08 17:23:57 +01:00
|
|
|
# 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'
|
|
|
|
'';
|
2023-02-20 12:10:35 +01:00
|
|
|
}
|
2021-02-20 15:37:39 +01:00
|
|
|
{
|
|
|
|
# Show when prefix has been pressed
|
|
|
|
plugin = prefix-highlight;
|
|
|
|
extraConfig = ''
|
|
|
|
# Also show when I'm in copy or sync mode
|
|
|
|
set -g @prefix_highlight_show_copy_mode 'on'
|
|
|
|
set -g @prefix_highlight_show_sync_mode 'on'
|
|
|
|
# Show prefix mode in status bar
|
|
|
|
set -g status-right '#{prefix_highlight} %a %Y-%m-%d %H:%M'
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
2021-02-20 15:46:39 +01:00
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
# Better vim mode
|
|
|
|
bind-key -T copy-mode-vi 'v' send -X begin-selection
|
2022-02-08 17:23:57 +01:00
|
|
|
${
|
|
|
|
lib.optionalString
|
|
|
|
(!hasGUI)
|
|
|
|
"bind-key -T copy-mode-vi 'y' send -X copy-selection"
|
|
|
|
}
|
2021-10-15 17:13:02 +02:00
|
|
|
# Block selection in vim mode
|
|
|
|
bind-key -Tcopy-mode-vi 'C-v' send -X begin-selection \; send -X rectangle-toggle
|
2023-02-12 13:03:10 +01:00
|
|
|
|
|
|
|
# Allow any application to send OSC52 escapes to set the clipboard
|
|
|
|
set -s set-clipboard on
|
2023-03-16 16:45:15 +01:00
|
|
|
|
2023-07-04 16:58:03 +02:00
|
|
|
# Longer session names in status bar
|
|
|
|
set -g status-left-length 16
|
|
|
|
|
2023-03-16 16:45:15 +01:00
|
|
|
${
|
2023-08-11 15:02:20 +02:00
|
|
|
lib.optionalString cfg.enablePassthrough ''
|
2023-03-16 16:45:15 +01:00
|
|
|
# Allow any application to use the tmux DCS for passthrough
|
|
|
|
set -g allow-passthrough on
|
|
|
|
''
|
|
|
|
}
|
2023-10-26 20:37:04 +02:00
|
|
|
|
2024-03-07 16:44:17 +01:00
|
|
|
# Force OSC8 hyperlinks for each relevant $TERM
|
|
|
|
${mkTerminalFlags "hyperlinks" "hyperlinks"}
|
2023-10-26 20:37:04 +02:00
|
|
|
# Force 24-bit color for each relevant $TERM
|
2024-03-07 16:42:58 +01:00
|
|
|
${mkTerminalFlags "trueColor" "RGB"}
|
2021-02-20 15:46:39 +01:00
|
|
|
'';
|
2021-02-20 15:34:33 +01:00
|
|
|
};
|
|
|
|
}
|