1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-14 13:01:09 +01:00

starship: add enableInteractive option for fish

Some fish plugins such as https://github.com/acomagu/fish-async-prompt
require that starship be initialized as non-interactive.

When the `programs.starship.enableInteractive` option is enabled,
starship is initialized at the end of the init script, outside the
interactive block.
This commit is contained in:
eljamm 2024-07-24 11:48:42 +01:00 committed by Robert Helgesson
parent 1cd17a2f76
commit 86ee1290d7
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
5 changed files with 100 additions and 1 deletions

View file

@ -2,4 +2,6 @@
starship-settings = ./settings.nix;
starship-fish-with-transience = ./fish_with_transience.nix;
starship-fish-without-transience = ./fish_without_transience.nix;
starship-fish-with-interactive = ./fish_with_interactive.nix;
starship-fish-without-interactive = ./fish_without_interactive.nix;
}

View file

@ -0,0 +1,27 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs = {
fish.enable = true;
starship.enable = true;
};
nmt.script = ''
assertFileExists home-files/.config/fish/config.fish
export GOT="$(tail -n 5 `_abs home-files/.config/fish/config.fish`)"
export NOT_EXPECTED="
if test \"\$TERM\" != dumb
/home/hm-user/.nix-profile/bin/starship init fish | source
end"
if [[ "$GOT" == "$NOT_EXPECTED" ]]; then
fail "Expected starship init to be inside the 'is-interactive' block but it wasn't."
fi
'';
};
}

View file

@ -0,0 +1,43 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs = {
fish.enable = true;
starship = {
enable = true;
enableInteractive = false;
};
};
nmt.script = ''
assertFileExists home-files/.config/fish/config.fish
export GOT="$(tail -n 5 `_abs home-files/.config/fish/config.fish`)"
export EXPECTED="
if test \"\$TERM\" != dumb
eval (/home/hm-user/.nix-profile/bin/starship init fish)
end"
export MESSAGE="
==========
Expected
==========
$EXPECTED
==========
Got
==========
$GOT
==========
"
if [[ "$GOT" != "$EXPECTED" ]]; then
fail "$MESSAGE"
fi
'';
};
}