Files
nix-config/users/modules/shell/starship.nix

78 lines
2.3 KiB
Nix
Raw Normal View History

2025-05-04 02:47:36 +02:00
{
config,
lib,
...
}:
with lib; let
2025-07-27 22:50:25 +02:00
cfg = config.home.shell.starship;
2025-05-04 02:47:36 +02:00
in {
2025-07-27 22:50:25 +02:00
options.home.shell.starship = {
2025-05-04 02:47:36 +02:00
enable = mkEnableOption "Enables the starship prompt.";
2025-07-27 22:50:25 +02:00
jjIntegration = mkOption {
description = "Enable Jujutsu integration in starship";
default = config.programs.jujutsu.enable;
type = types.bool;
};
2025-05-04 02:47:36 +02:00
};
config.programs.starship = mkIf cfg.enable {
inherit (cfg) enable;
enableTransience = true;
2025-07-27 22:50:25 +02:00
settings = mkIf cfg.jjIntegration {
# Disabling these so they can be enabled conditionally
# See https://github.com/jj-vcs/jj/wiki/Starship
git_status.disabled = true;
git_commit.disabled = true;
git_metrics.disabled = true;
git_branch.disabled = true;
custom = let
when = "! jj --ignore-working-copy-root";
description = "Only show if were not in a jj repository";
style = "";
in {
git_status = {
inherit when description style;
command = "starship module git_status";
};
git_commit = {
inherit when description style;
command = "starship module git_commit";
};
git_metrics = {
inherit when description style;
command = "starship module git_metrics";
};
git_branch = {
inherit when description style;
command = "starship module git_branch";
};
jj = {
description = "The current jj status";
detect_folders = [".jj"];
symbol = "🥋 ";
command = ''
jj log --revisions @ --no-graph --ignore-working-copy --color always --limit 1 --template '
separate(" ",
change_id.shortest(4),
bookmarks,
"|",
concat(
if(conflict, "💥"),
if(divergent, "🚧"),
if(hidden, "👻"),
if(immutable, "🔒"),
),
raw_escape_sequence("\x1b[1;32m") ++ if(empty, "(empty)"),
raw_escape_sequence("\x1b[1;32m") ++ coalesce(
truncate_end(29, description.first_line(), ""),
"(no description set)",
) ++ raw_escape_sequence("\x1b[0m"),
)
'
'';
};
2025-05-04 02:47:36 +02:00
};
};
};
}