This commit is contained in:
root 2026-03-16 12:19:11 -03:00
commit 73ff9ee8ee
No known key found for this signature in database
31 changed files with 4906 additions and 0 deletions

200
home/tmux.nix Normal file
View file

@ -0,0 +1,200 @@
{
config,
pkgs,
lib,
...
}:
with lib;
let
cfg = config.custom.tmux;
whichKeyConfig = pkgs.writeText "tmux-which-key-config.yaml" (
lib.generators.toYAML { } {
command_alias_start_index = 200;
keybindings = {
prefix_table = "Space";
};
title = {
style = "align=centre,bold";
prefix = "tmux";
prefix_style = "fg=green,align=centre,bold";
};
custom_variables = { };
macros = [ ];
position = {
x = "R";
y = "P";
};
items = [
{
name = "Window 1";
key = "n";
command = "select-window -t 1";
}
{
name = "Window 2";
key = "e";
command = "select-window -t 2";
}
{
name = "Window 3";
key = "i";
command = "select-window -t 3";
}
{
name = "Window 4";
key = "a";
command = "select-window -t 4";
}
{
name = "Next window";
key = "Enter";
command = "next-window";
transient = true;
}
{
name = "Last window";
key = "Space";
command = "last-window";
}
{
separator = true;
}
{
name = "Copy mode";
key = "BSpace";
command = "copy-mode";
}
{
separator = true;
}
{
name = "New window";
key = "l";
command = "new-window";
}
{
name = "New pane (vertical line)";
key = ",";
command = "splitw -h -c #{pane_current_path}";
}
{
name = "Split (horizontal line)";
key = "h";
command = "splitw -v -c #{pane_current_path}";
}
{
separator = true;
}
{
name = "Sessions";
key = "m";
menu = [
{
name = "sessionizer";
key = "Space";
command = "run-shell \"tmux neww tmux-sessionizer\"";
}
{
name = "last-session";
key = "Enter";
command = "run-shell \"tmux switchc -l\"";
}
];
}
{
separator = true;
}
{
name = "Kill";
key = "k";
menu = [
{
name = "Kill window";
key = "w";
command = "kill-window";
}
{
name = "Kill pane";
key = "p";
command = "kill-pane";
}
];
}
];
}
);
in
{
options.custom.tmux = {
enable = mkEnableOption "Custom Tmux";
};
config = mkIf cfg.enable {
programs.tmux = {
enable = true;
baseIndex = 1;
keyMode = "vi";
mouse = true;
plugins = with pkgs.tmuxPlugins; [
sensible
yank
pain-control
# tmux-powerline
{
plugin = rose-pine;
extraConfig = ''
set -g @rose_pine_variant 'main' # Options are 'main', 'moon' or 'dawn'
set -g @rose_pine_host 'on'
set -g @rose_pine_directory 'on'
set -g @rose_pine_bar_bg_disable 'on'
'';
}
{
plugin = pkgs.tmuxPlugins.tmux-which-key.overrideAttrs (old: {
postInstall = (old.postInstall or "") + ''
echo "[tmux-which-key] Pre-generating configuration at build time..."
${lib.getExe (pkgs.python3.withPackages (ps: with ps; [ pyyaml ]))} \
$target/plugin/build.py \
${whichKeyConfig} \
$target/init.tmux
# Append a line to source the pre-generated config
echo 'tmux source-file "$root_dir/init.tmux"' >> $target/plugin.sh.tmux
'';
});
extraConfig = ''
set -g @tmux-which-key-xdg-enable 1;
set -g @tmux-which-key-disable-autobuild 1;
'';
}
{
plugin = resurrect;
extraConfig = "set -g @ressurect-strategy-nvim 'session'";
}
{
plugin = continuum;
extraConfig = ''
set -g @continuum-restore 'on'
set -g @continuum-save-interval '60'
'';
}
];
extraConfig = ''
set -g status-position top
set -g focus-events on
set -g allow-passthrough on
set -s extended-keys on
set -g default-terminal "xterm-ghostty"
set -as terminal-features ",xterm-ghostty:extkeys"
bind -n M-, run-shell "tmux neww tmux-sessionizer"
bind -n M-/ run-shell "tmux switch-client -t default"
bind -n M-. run-shell "tmux switchc -l"
bind-key -n Home send Escape "OH"
bind-key -n End send Escape "OF"
'';
};
};
}