From a4eb3d531c79b4ad8ca6c9a0736ee9304c7bbae0 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 27 Oct 2024 23:08:17 +0100 Subject: common/starship: add custom jj elements --- common/commandline/starship.nix | 45 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/commandline/starship.nix b/common/commandline/starship.nix index 5983d2e..a17f9e8 100644 --- a/common/commandline/starship.nix +++ b/common/commandline/starship.nix @@ -1,4 +1,8 @@ -inputs: {lib, ...}: { +_inputs: +{ lib, pkgs, ... }: +{ + users.extraUsers.minijackson.packages = [ pkgs.sd ]; + home-manager.users.minijackson = { programs.starship = { enable = true; @@ -18,6 +22,45 @@ inputs: {lib, ...}: { nix_shell.style = "bold blue"; package.style = "bold green"; rust.style = "bold dimmed yellow"; + + custom = { + jj = { + command = '' + jj log -r@ -l1 --ignore-working-copy --no-graph --color always -T ' + separate(" ", + bookmarks.map(|x| if( + x.name().substr(0, 10).starts_with(x.name()), + x.name().substr(0, 10), + x.name().substr(0, 9) ++ "…") + ).join(" "), + tags.map(|x| if( + x.name().substr(0, 10).starts_with(x.name()), + x.name().substr(0, 10), + x.name().substr(0, 9) ++ "…") + ).join(" "), + surround("\"","\"", + if( + description.first_line().substr(0, 24).starts_with(description.first_line()), + description.first_line().substr(0, 24), + description.first_line().substr(0, 23) ++ "…" + ) + ), + if(conflict, "conflict"), + if(divergent, "divergent"), + if(hidden, "hidden"), + ) + ' + ''; + detect_folders = [ ".jj" ]; + symbol = "jj "; + }; + jjstate = { + command = '' + jj log -r@ -n1 --no-graph -T "" --stat | tail -n1 | sd "(\d+) files? changed, (\d+) insertions?\(\+\), (\d+) deletions?\(-\)" ' ''${1}m ''${2}+ ''${3}-' | sd " 0." "" + ''; + detect_folders = [ ".jj" ]; + }; + }; } (lib.importTOML ./starship-plain-text-symbols.toml) -- cgit v1.2.3