From 804c8b98d0012e1f85786c5f9ac907b37bff95a4 Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sat, 16 Nov 2024 20:47:47 -0800 Subject: [PATCH] feat(home): tmux --- homes/x86_64-linux/marley@nyx/default.nix | 1 + modules/home/programs/tmux/default.nix | 163 ++++++++++++++++++++++ old/home/programs/tmux.nix | 150 -------------------- 3 files changed, 164 insertions(+), 150 deletions(-) create mode 100644 modules/home/programs/tmux/default.nix delete mode 100644 old/home/programs/tmux.nix diff --git a/homes/x86_64-linux/marley@nyx/default.nix b/homes/x86_64-linux/marley@nyx/default.nix index 1c7192f..82ad135 100644 --- a/homes/x86_64-linux/marley@nyx/default.nix +++ b/homes/x86_64-linux/marley@nyx/default.nix @@ -41,6 +41,7 @@ in ssh = enabled; starship = enabled; systemctl = enabled; + tmux = enabled; }; xorg = { xsession = enabled; diff --git a/modules/home/programs/tmux/default.nix b/modules/home/programs/tmux/default.nix new file mode 100644 index 0000000..46fc279 --- /dev/null +++ b/modules/home/programs/tmux/default.nix @@ -0,0 +1,163 @@ +{ + lib, + config, + namespace, + pkgs, + ... +}: +let + inherit (lib) mkIf; + inherit (lib.${namespace}) mkEnableModule; + + cfg = config.${namespace}.programs.tmux; + inherit (config.${namespace}) theme; +in +{ + options = mkEnableModule "programs.tmux"; + + config = mkIf cfg.enable { + programs.tmux = { + enable = true; + + rose-pine = mkIf (theme.colors.base == "rose-pine") { + enable = true; + extraConfig = # tmux + '' + set -g @rose_pine_host 'on' + set -g @rose_pine_directory 'on' + ''; + }; + + terminal = "tmux-256color"; + + escapeTime = 0; + + # Start window & pane numbering at 1. + baseIndex = 1; + + # Vi mode. + keyMode = "vi"; + customPaneNavigationAndResize = true; + mouse = true; + + # Auto-spawn a new session when attaching if none exist. + newSession = true; + + # Key used with Ctrl to make the prefix. + shortcut = "a"; + + plugins = with pkgs.tmuxPlugins; [ + { + plugin = resurrect; + } + + { + plugin = continuum; + extraConfig = # tmux + '' + set -g @continuum-restore 'on' + ''; + } + + { + plugin = tilish; + extraConfig = # tmux + '' + # Don't enforce the layout. + set -g @tilish-enforce 'none' + + set -g @tilish-project "$HOME/hackin" + set -g @tilish-navigator 'on' + ''; + } + + { + plugin = vim-tmux-navigator; + } + + yank + + { + plugin = jump; + extraConfig = # tmux + '' + set -g @jump-key 's' + ''; + } + + { + plugin = fingers; + extraConfig = # tmux + '' + set -g @fingers-jump-key 'f' + ''; + } + + { + plugin = tmux-floax; + extraConfig = # tmux + '' + set -g @floax-bind 'i' + set -g @floax-text-color 'white' + ''; + } + ]; + + extraConfig = # tmux + '' + # Set repeat timeout so keys can be repeated without the prefix. + set -g repeat-time 1000 + + # Auto-renumber windows when one is deleted. + set -g renumber-windows 'on' + + set -ag terminal-overrides ",*:RGB" + + set -g status-position 'top' + + ### Keybindings ### + + # Easy reload config. + bind r source-file ${config.xdg.configHome}/tmux/tmux.conf \; display-message "Reloaded config" + + # Better split commands. + bind -N 'vsplit' | split-window -h -c "#{pane_current_path}" + bind -N 'vsplit' \\ split-window -h -c "#{pane_current_path}" + bind -N 'hsplit' - split-window -v -c "#{pane_current_path}" + unbind '"' + unbind % + + # Vi-like resizing. + bind -r -N 'Resize pane (left)' M-h resize-pane -L 5 + bind -r -N 'Resize pane (down)' M-j resize-pane -D 5 + bind -r -N 'Resize pane (up)' M-k resize-pane -U 5 + bind -r -N 'Resize pane (right)' M-l resize-pane -R 5 + + # Even out panes. + bind -N 'Evenly distribute panes' = select-layout -E + + # Swap panes. + bind -r -N 'Swap current pane with the next' H swap-pane -U + bind -r -N 'Swap current pane with the previous' L swap-pane -D + + # Window switching. + bind -N 'Previous window' Left previous-window + bind -N 'Next window' Right next-window + + # Vi copy mode. + unbind [ + bind -N 'Enter normal (copy) mode' Escape copy-mode + + bind -T copy-mode-vi ? command-prompt -p '?' 'send -X search-backward %1' + bind -T copy-mode-vi / command-prompt -p '/' 'send -X search-forward %1' + bind -T copy-mode-vi q send -X cancel + bind -T copy-mode-vi Escape if-shell -F '#{selection_present}' 'send -X clear-selection' 'send -X cancel' + ''; + }; + + home.shellAbbrs = { + tmain = "tmux new -s main -A"; + tmobile = "tmux new -s mobile -A"; + }; + }; +} diff --git a/old/home/programs/tmux.nix b/old/home/programs/tmux.nix deleted file mode 100644 index 2d749a2..0000000 --- a/old/home/programs/tmux.nix +++ /dev/null @@ -1,150 +0,0 @@ -{ - pkgs, - config, - ... -}: -{ - programs.tmux = { - enable = true; - - rose-pine = { - enable = true; - extraConfig = # tmux - '' - set -g @rose_pine_host 'on' - set -g @rose_pine_directory 'on' - ''; - }; - - terminal = "tmux-256color"; - - escapeTime = 0; - - # Start window & pane numbering at 1. - baseIndex = 1; - - # Vi mode. - keyMode = "vi"; - customPaneNavigationAndResize = true; - mouse = true; - - # Auto-spawn a new session when attaching if none exist. - newSession = true; - - # Key used with Ctrl to make the prefix. - shortcut = "a"; - - plugins = with pkgs.tmuxPlugins; [ - { - plugin = resurrect; - } - - { - plugin = continuum; - extraConfig = # tmux - '' - set -g @continuum-restore 'on' - ''; - } - - { - plugin = tilish; - extraConfig = # tmux - '' - # Don't enforce the layout. - set -g @tilish-enforce 'none' - - set -g @tilish-project "$HOME/hackin" - set -g @tilish-navigator 'on' - ''; - } - - { - plugin = vim-tmux-navigator; - } - - yank - - { - plugin = jump; - extraConfig = # tmux - '' - set -g @jump-key 's' - ''; - } - - { - plugin = fingers; - extraConfig = # tmux - '' - set -g @fingers-jump-key 'f' - ''; - } - - { - plugin = tmux-floax; - extraConfig = # tmux - '' - set -g @floax-bind 'i' - set -g @floax-text-color 'white' - ''; - } - ]; - - extraConfig = # tmux - '' - # Set repeat timeout so keys can be repeated without the prefix. - set -g repeat-time 1000 - - # Auto-renumber windows when one is deleted. - set -g renumber-windows 'on' - - set -ag terminal-overrides ",*:RGB" - - set -g status-position 'top' - - ### Keybindings ### - - # Easy reload config. - bind r source-file ${config.xdg.configHome}/tmux/tmux.conf \; display-message "Reloaded config" - - # Better split commands. - bind -N 'vsplit' | split-window -h -c "#{pane_current_path}" - bind -N 'vsplit' \\ split-window -h -c "#{pane_current_path}" - bind -N 'hsplit' - split-window -v -c "#{pane_current_path}" - unbind '"' - unbind % - - # Vi-like resizing. - bind -r -N 'Resize pane (left)' M-h resize-pane -L 5 - bind -r -N 'Resize pane (down)' M-j resize-pane -D 5 - bind -r -N 'Resize pane (up)' M-k resize-pane -U 5 - bind -r -N 'Resize pane (right)' M-l resize-pane -R 5 - - # Even out panes. - bind -N 'Evenly distribute panes' = select-layout -E - - # Swap panes. - bind -r -N 'Swap current pane with the next' H swap-pane -U - bind -r -N 'Swap current pane with the previous' L swap-pane -D - - # Window switching. - bind -N 'Previous window' Left previous-window - bind -N 'Next window' Right next-window - - # Vi copy mode. - unbind [ - bind -N 'Enter normal (copy) mode' Escape copy-mode - - bind -T copy-mode-vi ? command-prompt -p '?' 'send -X search-backward %1' - bind -T copy-mode-vi / command-prompt -p '/' 'send -X search-forward %1' - bind -T copy-mode-vi q send -X cancel - bind -T copy-mode-vi Escape if-shell -F '#{selection_present}' 'send -X clear-selection' 'send -X cancel' - ''; - }; - - home.shellAbbrs = { - tmain = "tmux new -s main -A"; - tmobile = "tmux new -s mobile -A"; - }; -}