diff --git a/modules/programs/starship.nix b/modules/programs/starship.nix index 31136d7e..519c9c02 100644 --- a/modules/programs/starship.nix +++ b/modules/programs/starship.nix @@ -77,6 +77,19 @@ in { enableNushellIntegration = mkEnableOption "Nushell integration" // { default = true; }; + + enableTransience = mkOption { + type = types.bool; + default = false; + description = '' + The TransientPrompt feature of Starship replaces previous prompts with a + custom string. This is only a valid option for the Fish shell. + + For documentation on how to change the default replacement string and + for more information visit + https://starship.rs/advanced-config/#transientprompt-and-transientrightprompt-in-cmd + ''; + }; }; config = mkIf cfg.enable { @@ -101,6 +114,7 @@ in { programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration '' if test "$TERM" != "dumb" -a \( -z "$INSIDE_EMACS" -o "$INSIDE_EMACS" = "vterm" \) eval (${starshipCmd} init fish) + ${lib.optionalString cfg.enableTransience "enable_transience"} end ''; diff --git a/tests/modules/programs/starship/default.nix b/tests/modules/programs/starship/default.nix index 814aed65..6fed1303 100644 --- a/tests/modules/programs/starship/default.nix +++ b/tests/modules/programs/starship/default.nix @@ -1 +1,5 @@ -{ starship-settings = ./settings.nix; } +{ + starship-settings = ./settings.nix; + starship-fish-with-transience = ./fish_with_transience.nix; + starship-fish-without-transience = ./fish_without_transience.nix; +} diff --git a/tests/modules/programs/starship/fish_with_transience.nix b/tests/modules/programs/starship/fish_with_transience.nix new file mode 100644 index 00000000..c7a0fbf5 --- /dev/null +++ b/tests/modules/programs/starship/fish_with_transience.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs = { + fish.enable = true; + + starship = { + enable = true; + enableTransience = true; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/fish/config.fish + assertFileRegex home-files/.config/fish/config.fish 'enable_transience' + ''; + }; +} diff --git a/tests/modules/programs/starship/fish_without_transience.nix b/tests/modules/programs/starship/fish_without_transience.nix new file mode 100644 index 00000000..7ba8e67f --- /dev/null +++ b/tests/modules/programs/starship/fish_without_transience.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs = { + fish.enable = true; + starship.enable = true; + }; + + nmt.script = '' + assertFileExists home-files/.config/fish/config.fish + assertFileNotRegex home-files/.config/fish/config.fish 'enable_transience' + ''; + }; +}