nixos-config/home-manager/tmux.nix
2024-08-21 13:39:57 +02:00

57 lines
2.3 KiB
Nix

{ pkgs, ... }:
{
programs.tmux = {
enable = true;
clock24 = true;
escapeTime = 0;
keyMode = "vi";
mouse = false;
shortcut = "a";
extraConfig = ''
bind h split -hb -c '#{pane_current_path}'
bind j split -v -c '#{pane_current_path}'
bind k split -vb -c '#{pane_current_path}'
bind l split -h -c '#{pane_current_path}'
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' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' 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
set -g pane-border-style bg=default
set -g pane-border-style fg="#1D1F21"
set -g pane-active-border-style bg=default
set -g pane-active-border-style fg="#333333"
set-option -g status on
set-option -g status-style bg=default
set-option -g status-style fg="#ef7627"
set-option -g status-interval 2
set-option -g status-justify "centre"
set-option -g status-right " λ "
set -g status-interval 1
set-window-option -g window-status-separator "-"
set-window-option -g window-status-current-format " #[fg=#b55690 bold]!![ #{b:pane_current_path}/ ] #{b:window_index} $ #{b:pane_current_command}!! "
set-window-option -g window-status-format " #{b:window_index} [ #{b:pane_current_path}/ ] #{b:pane_current_command} "
'';
};
}