mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 06:59:45 +01:00
starship: add enable_transience for fish (#3975)
Starship has an advanced, experimental feature where fancy stuff in the prompt can be replaced with something more simple after the command is ran. This is very helpful for copy and pasting shell history somewhere else. docs: https://starship.rs/advanced-config/#transientprompt-and-transientrightprompt-in-fish Fish is currently the only shell as far as I can tell that both home-manager and starship support for this feature. Since the function has to be called after starship is loaded, this seems like the best place to put it. format
This commit is contained in:
parent
6bdd72b914
commit
f06a43dca0
4 changed files with 57 additions and 1 deletions
|
@ -77,6 +77,19 @@ in {
|
||||||
enableNushellIntegration = mkEnableOption "Nushell integration" // {
|
enableNushellIntegration = mkEnableOption "Nushell integration" // {
|
||||||
default = true;
|
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 {
|
config = mkIf cfg.enable {
|
||||||
|
@ -101,6 +114,7 @@ in {
|
||||||
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
||||||
if test "$TERM" != "dumb" -a \( -z "$INSIDE_EMACS" -o "$INSIDE_EMACS" = "vterm" \)
|
if test "$TERM" != "dumb" -a \( -z "$INSIDE_EMACS" -o "$INSIDE_EMACS" = "vterm" \)
|
||||||
eval (${starshipCmd} init fish)
|
eval (${starshipCmd} init fish)
|
||||||
|
${lib.optionalString cfg.enableTransience "enable_transience"}
|
||||||
end
|
end
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
21
tests/modules/programs/starship/fish_with_transience.nix
Normal file
21
tests/modules/programs/starship/fish_with_transience.nix
Normal file
|
@ -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'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
17
tests/modules/programs/starship/fish_without_transience.nix
Normal file
17
tests/modules/programs/starship/fish_without_transience.nix
Normal file
|
@ -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'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue