From 9c14bbe988f4a085863b3f39e0215109dc446485 Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Tue, 15 Oct 2019 10:23:32 +0800 Subject: [PATCH] tmux: allow setting default-shell before new-session --- modules/programs/tmux.nix | 13 +++++++- .../modules/programs/tmux/default-shell.conf | 30 +++++++++++++++++++ tests/modules/programs/tmux/default-shell.nix | 27 +++++++++++++++++ tests/modules/programs/tmux/default.nix | 1 + 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/modules/programs/tmux/default-shell.conf create mode 100644 tests/modules/programs/tmux/default-shell.nix diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix index a71c302ac..e28145da1 100644 --- a/modules/programs/tmux.nix +++ b/modules/programs/tmux.nix @@ -27,6 +27,7 @@ let defaultResize = 5; defaultShortcut = "b"; defaultTerminal = "screen"; + defaultShell = null; boolToStr = value: if value then "on" else "off"; @@ -41,7 +42,10 @@ let set -g default-terminal "${cfg.terminal}" set -g base-index ${toString cfg.baseIndex} setw -g pane-base-index ${toString cfg.baseIndex} - + ${optionalString (cfg.shell != null) '' + # We need to set default-shell before calling new-session + set -g default-shell "${cfg.shell}" + ''} ${optionalString cfg.newSession "new-session"} ${optionalString cfg.reverseSplit '' @@ -250,6 +254,13 @@ in description = "Set the $TERM variable."; }; + shell = mkOption { + default = defaultShell; + example = "\${pkgs.zsh}/bin/zsh"; + type = with types; nullOr str; + description = "Set the default-shell tmux variable."; + }; + secureSocket = mkOption { default = pkgs.stdenv.isLinux; type = types.bool; diff --git a/tests/modules/programs/tmux/default-shell.conf b/tests/modules/programs/tmux/default-shell.conf new file mode 100644 index 000000000..a33623630 --- /dev/null +++ b/tests/modules/programs/tmux/default-shell.conf @@ -0,0 +1,30 @@ +# ============================================= # +# Start with defaults from the Sensible plugin # +# --------------------------------------------- # +run-shell @sensible_rtp@ +# ============================================= # + +set -g default-terminal "screen" +set -g base-index 0 +setw -g pane-base-index 0 +# We need to set default-shell before calling new-session +set -g default-shell "/usr/bin/myshell" + + + + + +set -g status-keys emacs +set -g mode-keys emacs + + + + + + + +setw -g aggressive-resize off +setw -g clock-mode-style 12 +set -s escape-time 500 +set -g history-limit 2000 + diff --git a/tests/modules/programs/tmux/default-shell.nix b/tests/modules/programs/tmux/default-shell.nix new file mode 100644 index 000000000..05091c6ab --- /dev/null +++ b/tests/modules/programs/tmux/default-shell.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + substituteExpected = path: + pkgs.substituteAll { + src = path; + + sensible_rtp = pkgs.tmuxPlugins.sensible.rtp; + }; + +in { + config = { + programs.tmux = { + enable = true; + shell = "/usr/bin/myshell"; + }; + + nmt.script = '' + assertFileExists home-files/.tmux.conf + assertFileContent home-files/.tmux.conf \ + ${substituteExpected ./default-shell.conf} + ''; + }; +} diff --git a/tests/modules/programs/tmux/default.nix b/tests/modules/programs/tmux/default.nix index d4501c609..f0a997b7e 100644 --- a/tests/modules/programs/tmux/default.nix +++ b/tests/modules/programs/tmux/default.nix @@ -4,4 +4,5 @@ tmux-vi-all-true = ./vi-all-true.nix; tmux-secure-socket-enabled = ./secure-socket-enabled.nix; tmux-disable-confirmation-prompt = ./disable-confirmation-prompt.nix; + tmux-default-shell = ./default-shell.nix; }