shell/starship: add git short status

This commit is contained in:
Anthony Rodriguez 2025-02-10 19:02:35 +01:00
parent b6d62c71fe
commit a6e1683060
Signed by: nezia
SSH key fingerprint: SHA256:Ihfpl0rUpqDevYqnzSR34OYfVLbDNkBiUjs3CpX4ykA

View file

@ -4,14 +4,15 @@
config, config,
... ...
}: let }: let
inherit (config.local.systemVars) username; inherit (lib.strings) concatStrings;
toTOML = (pkgs.formats.toml {}).generate; toTOML = (pkgs.formats.toml {}).generate;
inherit (config.local.systemVars) username;
in { in {
config = lib.mkIf config.local.profiles.desktop.enable { config = lib.mkIf config.local.profiles.desktop.enable {
hjem.users.${username} = { hjem.users.${username} = {
packages = [pkgs.starship]; packages = [pkgs.starship];
files = { files = {
".config/starship/config.toml".source = toTOML "starship config" { ".config/starship.toml".source = toTOML "starship config" {
add_newline = true; add_newline = true;
directory = { directory = {
style = "bold yellow"; style = "bold yellow";
@ -25,6 +26,43 @@ in {
style = "yellow"; style = "yellow";
format = "[ $duration]($style)"; format = "[ $duration]($style)";
}; };
# https://github.com/llakala/nixos/blob/6e840f11d19e59b49e7ba9573f1398830799758a/apps/core/starship/git_status.nix
git_status = {
modified = "M";
staged = "S";
untracked = "A";
renamed = "R";
deleted = "D";
conflicted = "U";
ahead = "[+$count](green)";
behind = "[-$count](red)";
diverged = "[+$ahead_count](green),[-$behind_count](red)";
style = "white";
# referenced from https://github.com/clotodex/nix-config/blob/c878ff5d5ae674b49912387ea9253ce985cbd3cd/shell/starship.nix#L82
format =
concatStrings
[
"[("
"(\\["
"[($conflicted)](orange)"
"[($stashed)](white)"
"[($staged)](blue)"
"[($deleted)](red)"
"[($renamed)](yellow)"
"[($modified)](yellow)"
"[($untracked)](green)"
"\\])"
"( \\[$ahead_behind\\])"
" )]"
"($style)"
];
};
}; };
}; };
}; };