{...}: {
  programs.tmux = {
    enable = true;
    keyMode = "vi";
    terminal = "tmux-256color";
    escapeTime = 0;
    baseIndex = 1;
    historyLimit = 10000;
    clock24 = true;
    extraConfig = ''
      unbind-key -a -T prefix
      unbind-key -a -T root
      unbind-key -a -T copy-mode
      unbind-key -a -T copy-mode-vi

      set -g prefix M-w

      bind q detach
      bind space copy-mode
      bind -T copy-mode-vi Escape send-keys -X cancel

      bind -T copy-mode-vi Escape send -X cancel
      bind -T copy-mode-vi k send -X cursor-up
      bind -T copy-mode-vi j send -X cursor-down
      bind -T copy-mode-vi h send -X cursor-left
      bind -T copy-mode-vi l send -X cursor-right

      bind -T copy-mode-vi Space send -X begin-selection
      bind -T copy-mode-vi y send -X copy-selection-no-clear
      bind -T copy-mode-vi Enter send -X copy-selection-and-cancel

      set -g mouse on
      bind -n WheelUpPane copy-mode -e
      bind -T copy-mode-vi WheelUpPane send -X -N 5 scroll-up
      bind -T copy-mode-vi WheelDownPane send -X -N 5 scroll-down
    '';
  };
}
