@@ -5,8 +5,57 @@ let
6 cfg = config.programs.tmux;
6 cfg = config.programs.tmux;
8+ defaultKeyMode = "emacs";
10+ defaultShortcut = "b";
11+ defaultTerminal = "screen";
13+ boolToStr = value: if value then "on" else "off";
16+ set -g default-terminal "${cfg.terminal}"
17+ set -g base-index ${toString cfg.baseIndex}
18+ setw -g pane-base-index ${toString cfg.baseIndex}
20+ ${if cfg.newSession then "new-session" else ""}
22+ ${if cfg.reverseSplit then ''
23+ bind v split-window -h
24+ bind s split-window -v
27+ set -g status-keys ${cfg.keyMode}
28+ set -g mode-keys ${cfg.keyMode}
30+ ${if cfg.keyMode == "vi" then ''
31+ bind h select-pane -L
32+ bind j select-pane -D
33+ bind k select-pane -U
34+ bind l select-pane -R
36+ bind -r H resize-pane -L ${toString cfg.resizeAmount}
37+ bind -r J resize-pane -D ${toString cfg.resizeAmount}
38+ bind -r K resize-pane -U ${toString cfg.resizeAmount}
39+ bind -r L resize-pane -R ${toString cfg.resizeAmount}
42+ ${if (cfg.shortcut != defaultShortcut) then ''
43+ # rebind main key: C-${cfg.shortcut}
44+ unbind C-${defaultShortcut}
45+ set -g prefix C-${cfg.shortcut}
46+ bind ${cfg.shortcut} send-prefix
47+ bind C-${cfg.shortcut} last-window
50+ setw -g aggressive-resize ${boolToStr cfg.aggressiveResize}
51+ setw -g clock-mode-style ${if cfg.clock24 then "24" else "12"}
52+ set -s escape-time ${toString cfg.escapeTime}
53+ set -g history-limit ${toString cfg.historyLimit}
10 ###### interface
59 ###### interface
12 options = {
61 options = {
@@ -14,13 +63,92 @@ in
15 enable = mkEnableOption "<command>tmux</command> - a <command>screen</command> replacement.";
64 enable = mkEnableOption "<command>tmux</command> - a <command>screen</command> replacement.";
66+ aggressiveResize = mkOption {
71+ Resize the window to the size of the smallest session for which it is the current window.
75+ baseIndex = mkOption {
79+ description = "Base index for windows and panes.";
86+ description = "Use 24 hour clock.";
89+ escapeTime = mkOption {
93+ description = "Time in milliseconds for which tmux waits after an escape is input.";
17− tmuxconf = mkOption {
96+ extraTmuxConf = mkOption {
18 default = "";
97 default = "";
19 description = ''
98 description = ''
20− The contents of /etc/tmux.conf
99+ Additional contents of /etc/tmux.conf
22 type = types.lines;
101 type = types.lines;
104+ historyLimit = mkOption {
108+ description = "Maximum number of lines held in window history.";
111+ keyMode = mkOption {
112+ default = defaultKeyMode;
114+ type = types.enum [ "emacs" "vi" ];
115+ description = "VI or Emacs style shortcuts.";
118+ newSession = mkOption {
122+ description = "Automatically spawn a session if trying to attach and none are running.";
125+ reverseSplit = mkOption {
129+ description = "Reverse the window split shortcuts.";
132+ resizeAmount = mkOption {
133+ default = defaultResize;
136+ description = "Number of lines/columns when resizing.";
139+ shortcut = mkOption {
140+ default = defaultShortcut;
143+ description = "Ctrl following by this key is used as the main shortcut.";
146+ terminal = mkOption {
147+ default = defaultTerminal;
148+ example = "screen-256color";
150+ description = "Set the $TERM variable.";
@@ -29,7 +157,7 @@ in
29 config = mkIf cfg.enable {
157 config = mkIf cfg.enable {
30 environment = {
158 environment = {
31 systemPackages = [ pkgs.tmux ];
159 systemPackages = [ pkgs.tmux ];
32− etc."tmux.conf".text = cfg.tmuxconf;
160+ etc."tmux.conf".text = tmuxConf;