1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19: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:
Will Leinweber 2023-06-19 21:56:48 +02:00 committed by GitHub
parent 6bdd72b914
commit f06a43dca0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 1 deletions

View file

@ -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
'';

View file

@ -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;
}

View 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'
'';
};
}

View 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'
'';
};
}