diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 98f14906..82a9fbe8 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -123,6 +123,15 @@ in interactive shell. ''; }; + + logoutExtra = mkOption { + default = ""; + type = types.lines; + description = '' + Extra commands that should be run when logging out of an + interactive shell. + ''; + }; }; }; @@ -195,6 +204,14 @@ in ${cfg.bashrcExtra} ''; + home.file.".bash_logout" = mkIf (cfg.logoutExtra != "") { + text = '' + # -*- mode: sh -*- + + ${cfg.logoutExtra} + ''; + }; + home.packages = optional (cfg.enableAutojump) pkgs.autojump; } diff --git a/tests/modules/programs/bash/default.nix b/tests/modules/programs/bash/default.nix index 0d361adf..e9f431cd 100644 --- a/tests/modules/programs/bash/default.nix +++ b/tests/modules/programs/bash/default.nix @@ -1,3 +1,4 @@ { + bash-logout = ./logout.nix; bash-session-variables = ./session-variables.nix; } diff --git a/tests/modules/programs/bash/logout-expected.txt b/tests/modules/programs/bash/logout-expected.txt new file mode 100644 index 00000000..9462f58f --- /dev/null +++ b/tests/modules/programs/bash/logout-expected.txt @@ -0,0 +1,4 @@ +# -*- mode: sh -*- + +clear-console + diff --git a/tests/modules/programs/bash/logout.nix b/tests/modules/programs/bash/logout.nix new file mode 100644 index 00000000..8f96dc7e --- /dev/null +++ b/tests/modules/programs/bash/logout.nix @@ -0,0 +1,22 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.bash = { + enable = true; + + logoutExtra = '' + clear-console + ''; + }; + + nmt.script = '' + assertFileExists home-files/.bash_logout + assertFileContent \ + home-files/.bash_logout \ + ${./logout-expected.txt} + ''; + }; +}