From 12f6ea5f767c8b2a96f0e909720d3d6fbb71e0e1 Mon Sep 17 00:00:00 2001 From: Alex van de Sandt Date: Tue, 8 Sep 2026 22:50:07 -0500 Subject: [PATCH] Add jj module to starship prompt --- modules/shell/_starship.toml | 71 ++++++++++++++++++++++++++++++++++++ modules/shell/shell.nix | 10 ++--- modules/shell/starship.nix | 12 ++++++ 3 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 modules/shell/_starship.toml create mode 100644 modules/shell/starship.nix diff --git a/modules/shell/_starship.toml b/modules/shell/_starship.toml new file mode 100644 index 0000000..68d3d22 --- /dev/null +++ b/modules/shell/_starship.toml @@ -0,0 +1,71 @@ +# from the official wiki: https://github.com/jj-vcs/jj/wiki/Starship + +# custom module for jj status +[custom.jj] +description = "The current jj status" +when = "jj --ignore-working-copy root" +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"), + ) +' +''' + +# optionally disable git modules when JJ is found. +# note that you'll need to add ${custom.git_branch}, ${custom.git_commit} etc +# into format: https://starship.rs/config/#default-prompt-format +[git_status] +disabled = true + +[custom.git_status] +when = "! jj --ignore-working-copy root" # Slow without `require_repo = true` +require_repo = true # Avoids `when` eval overhead in plain dirs +command = "starship module git_status" +style = "" # This disables the default "(bold green)" style +description = "Only show git_status if we're not in a jj repo" + +[git_commit] +disabled = true + +[custom.git_commit] +when = "! jj --ignore-working-copy root" +require_repo = true +command = "starship module git_commit" +style = "" +description = "Only show git_commit if we're not in a jj repo" + + +[git_metrics] +disabled = true + +[custom.git_metrics] +when = "! jj --ignore-working-copy root" +require_repo = true +command = "starship module git_metrics" +description = "Only show git_metrics if we're not in a jj repo" +style = "" + +[git_branch] +disabled = true + +[custom.git_branch] +when = "! jj --ignore-working-copy root" +require_repo = true +command = "starship module git_branch" +description = "Only show git_branch if we're not in a jj repo" +style = "" diff --git a/modules/shell/shell.nix b/modules/shell/shell.nix index e258247..690422b 100644 --- a/modules/shell/shell.nix +++ b/modules/shell/shell.nix @@ -1,5 +1,7 @@ -{ +{ den, ... }: { den.aspects.shell = { + includes = [ den.aspects.starship ]; + homeManager = { home.shellAliases = { j = "just"; @@ -8,12 +10,6 @@ ndv = "nix develop -c nvim"; tree = "tree --gitignore"; }; - - programs.starship = { - enable = true; - enableZshIntegration = true; - enableBashIntegration = true; - }; }; }; } diff --git a/modules/shell/starship.nix b/modules/shell/starship.nix new file mode 100644 index 0000000..300635e --- /dev/null +++ b/modules/shell/starship.nix @@ -0,0 +1,12 @@ +{ + den.aspects.starship = { + homeManager = { + programs.starship.enable = true; + + home.file.starship = { + target = ".config/starship.toml"; + source = ./_starship.toml; + }; + }; + }; +} -- 2.51.2