This repository has been archived on 2024-05-02. You can view files and clone it, but cannot push or open issues or pull requests.
home-manager-flake/modules/shell/tmux.nix

88 lines
3.3 KiB
Nix

{ pkgs, ... }:
let
localLib = pkgs.callPackage ../../lib { };
catppuccin = pkgs.callPackage ../../pkgs/tmuxPlugins/catppuccin.nix {
inherit localLib;
};
in
{
programs.tmux = {
enable = true;
newSession = true;
mouse = true;
keyMode = "vi";
historyLimit = 10240;
clock24 = true;
baseIndex = 1;
aggressiveResize = true;
shortcut = "a";
sensibleOnTop = true;
escapeTime = 0;
tmuxp.enable = true;
plugins = with pkgs.tmuxPlugins; [
sensible
yank
{
plugin = catppuccin;
extraConfig = ''
set -g @catppuccin_window_default_text "#W" # use "#W" for application instead of directory
set -g @catppuccin_window_current_text "#W" # use "#W" for application instead of directory
set -g @catppuccin_window_status_enable "yes"
set -g @catppuccin_status_modules_right "directory user host date_time session"
'';
}
better-mouse-mode
{
plugin = tmux-fzf;
extraConfig = ''
unbind A
TMUX_FZF_LAUNCH_KEY="f"
TMUX_FZF_PANE_FORMAT="[#{window_name}] #{pane_current_command} [#{pane_width}x#{pane_height}] [history #{history_size}/#{history_limit}, #{history_bytes} bytes] #{?pane_active,[active],[inactive]}"
'';
}
];
extraConfig = ''
# Quick pane cycling
unbind ^A
bind ^A last-window
#unbind 'Space'
#bind 'Space' next-window
bind-key C-s split-window -v
bind-key C-v split-window -h
# Open new panes and windows with the current panes path
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
set-option -sa terminal-features ',xterm-256color:RGB'
set-option -sa terminal-features ',st-256color:RGB'
set-option -sa terminal-features ',xterm-kitty:RGB'
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?\.?(view|n?vim?x?)(-wrapped)?(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' "" 'select-pane -L' }
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' "" 'select-pane -D' }
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' "" 'select-pane -U' }
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' "" 'select-pane -R' }
bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' "" 'select-pane -L'
bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' "" 'select-pane -D'
bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' "" 'select-pane -U'
bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' "" 'select-pane -R'
bind -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'resize-pane -L 1'
bind -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'resize-pane -D 1'
bind -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'resize-pane -U 1'
bind -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'resize-pane -R 1'
bind-key -T copy-mode-vi M-h resize-pane -L 1
bind-key -T copy-mode-vi M-j resize-pane -D 1
bind-key -T copy-mode-vi M-k resize-pane -U 1
bind-key -T copy-mode-vi M-l resize-pane -R 1
'';
};
}