summaryrefslogtreecommitdiff
path: root/modules/programs/tmux.nix
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2016-11-06 22:38:31 +0100
committerDaiderd Jordan <daiderd@gmail.com>2016-11-06 22:38:31 +0100
commit926395d628aa4cf9c96f234e5039a2d117d8f67a (patch)
tree565024322564530bfcb5cde3244519eeb15e2997 /modules/programs/tmux.nix
parent50081e675e947c6c4271bfcf0dca76e1379e16b4 (diff)
reorganize modules
Diffstat (limited to 'modules/programs/tmux.nix')
-rw-r--r--modules/programs/tmux.nix123
1 files changed, 123 insertions, 0 deletions
diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix
new file mode 100644
index 0000000..18967d2
--- /dev/null
+++ b/modules/programs/tmux.nix
@@ -0,0 +1,123 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ inherit (pkgs) stdenv;
+
+ cfg = config.programs.tmux;
+
+ tmuxConfigs =
+ mapAttrsToList (n: v: "${v}") cfg.text;
+
+in {
+ options = {
+
+ programs.tmux.loginShell = mkOption {
+ type = types.path;
+ default = "$SHELL";
+ description = ''
+ Configure default login shell.
+ '';
+ };
+
+ programs.tmux.enableSensible = mkOption {
+ type = types.bool;
+ default = false;
+ example = true;
+ description = ''
+ Enable sensible configuration options.
+ '';
+ };
+
+ programs.tmux.enableMouse = mkOption {
+ type = types.bool;
+ default = false;
+ example = true;
+ description = ''
+ Enable mouse support.
+ '';
+ };
+
+ programs.tmux.enableVim = mkOption {
+ type = types.bool;
+ default = false;
+ example = true;
+ description = ''
+ Enable vim style keybindings for copy mode, and navigation of panes.
+ '';
+ };
+
+ programs.tmux.config = mkOption {
+ type = types.lines;
+ description = ''
+ Configuration options.
+ '';
+ };
+
+ programs.tmux.text = mkOption {
+ internal = true;
+ type = types.attrsOf types.lines;
+ default = {};
+ };
+
+ };
+
+ config = {
+
+ programs.tmux.config = concatStringsSep "\n" tmuxConfigs;
+
+ programs.tmux.text.login-shell = if stdenv.isDarwin then ''
+ set -g default-command "reattach-to-user-namespace ${cfg.loginShell}"
+ '' else ''
+ set -g default-command "${cfg.loginShell}"
+ '';
+
+ programs.tmux.text.sensible = mkIf cfg.enableSensible (''
+ set -g default-terminal "screen-256color"
+ setw -g aggressive-resize on
+
+ set -g base-index 1
+ set -g renumber-windows on
+
+ set -g status-keys emacs
+ set -s escape-time 0
+
+ bind c new-window -c '#{pane_current_path}'
+ bind % split-window -v -c '#{pane_current_path}'
+ bind '"' split-window -h -c '#{pane_current_path}'
+
+ # TODO: make these interactive
+ bind C new-session
+ bind S switch-client -l
+
+ # set -g status-utf8 on
+ # set -g utf8 on
+ '');
+
+ programs.tmux.text.mouse = mkIf cfg.enableMouse ''
+ set -g mouse on
+ setw -g mouse on
+ set -g terminal-overrides 'xterm*:smcup@:rmcup@'
+ '';
+
+ programs.tmux.text.vim = mkIf cfg.enableVim (''
+ setw -g mode-keys vi
+
+ bind h select-pane -L
+ bind j select-pane -D
+ bind k select-pane -U
+ bind l select-pane -R
+ bind s split-window -v -c '#{pane_current_path}'
+ bind v split-window -h -c '#{pane_current_path}'
+
+ bind -t vi-copy v begin-selection
+ '' + optionalString stdenv.isLinux ''
+ bind -t vi-copy y copy-selection
+ '' + optionalString stdenv.isDarwin ''
+ bind -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
+ '');
+
+ };
+}