feat(tmux): add keybinds option

nixos
Moritz Böhme 2023-04-28 08:11:44 +02:00
parent 56044695df
commit b23382ee8e
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
2 changed files with 39 additions and 2 deletions

View File

@ -64,6 +64,19 @@ in
gpg.enable = true; gpg.enable = true;
navi.enable = true; navi.enable = true;
tmux.enable = true; tmux.enable = true;
tmux.keybinds = {
prefix = {
"-" = "split-window -v";
"|" = "split-window -h";
"C-l" = "send-keys C-l";
"R" = "source-file $XDG_CONFIG_HOME/tmux/tmux.conf \\; display-message 'Reloaded tmux.conf'";
};
copy-mode-vi = {
"v" = "send -X begin-selection";
"V" = "send -X select-line";
"C-v" = "send -X rectangle-toggle";
};
};
}; };
}; };

View File

@ -9,7 +9,7 @@ let
runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd ]; runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd ];
text = '' text = ''
#!/usr/bin/env bash #!/usr/bin/env bash
options=$(fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | fzf --filter "''$*") options=$(fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | fzf --filter "''$*")
if [[ -z $options ]]; then if [[ -z $options ]]; then
@ -43,6 +43,22 @@ in
options.my.programs.tmux = { options.my.programs.tmux = {
enable = mkEnableOption "tmux"; enable = mkEnableOption "tmux";
autoAttach = mkEnableOption "autoAttach"; autoAttach = mkEnableOption "autoAttach";
keybinds = mkOption {
type = with types; attrsOf (attrsOf string);
default = { };
description = "Keybinds for tmux";
example = literalExample ''
{
prefix = {
"-" = "split-window -v";
"|" = "split-window -h";
};
copy-mode-vi = {
"v" = "send -X begin-selection";
};
}
'';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -64,6 +80,15 @@ in
tmux-fzf tmux-fzf
yank yank
]; ];
extraConfig =
let
mkKeybind = table: mapAttrsToList (keybind: value: "bind-key -T ${table} '${keybind}' ${value}");
keybinds = flatten (mapAttrsToList mkKeybind cfg.keybinds);
in
''
# Keybinds
${concatStringsSep "\n" keybinds}
'';
}; };
fzf.tmux.enableShellIntegration = true; fzf.tmux.enableShellIntegration = true;
fish.interactiveShellInit = fish.interactiveShellInit =
@ -80,7 +105,6 @@ in
end end
end end
''; '';
}; };
}; };
} }