diff --git a/home/nogui/oh-my-posh.nix b/home/nogui/oh-my-posh.nix index c051ddcb8b18cd1b7b88259f23716525f53966ec..91c69b51f9e5e87e47eed514ef59375b79cae3ad 100644 --- a/home/nogui/oh-my-posh.nix +++ b/home/nogui/oh-my-posh.nix @@ -1,6 +1,46 @@ { pkgs, ... }: let unicode = x: builtins.fromJSON ''"${x}"''; + jjScript = pkgs.writeShellApplication { + name = "jj-prompt"; + runtimeInputs = [ pkgs.jujutsu ]; + text = + let + bookmarkMax = 10; + tagMax = 10; + descriptionMax = 24; + in + '' + jj log -r@ -n1 --ignore-working-copy --no-graph --color never -T ' + separate(" ", + bookmarks.map(|x| if( + x.name().substr(0, ${builtins.toString bookmarkMax}).starts_with(x.name()), + "󰃀 " ++ x.name().substr(0, ${builtins.toString bookmarkMax}), + "󰃀 " ++ x.name().substr(0, ${builtins.toString (bookmarkMax - 1)}) ++ "…") + ).join(" "), + tags.map(|x| if( + x.name().substr(0, ${builtins.toString tagMax}).starts_with(x.name()), + "󰓹 " ++ x.name().substr(0, ${builtins.toString tagMax}), + "󰓹 " ++ x.name().substr(0, ${builtins.toString (tagMax - 1)}) ++ "…") + ).join(" "), + if( + description.first_line().substr(0, ${builtins.toString descriptionMax}).starts_with(description.first_line()), + "󰍡 " ++ description.first_line().substr(0, ${builtins.toString descriptionMax}), + "󰍡 " ++ description.first_line().substr(0, ${ + builtins.toString (descriptionMax - 1) + }) ++ "…" + ), + "•", + change_id.shortest(6).prefix() ++ "(" ++ change_id.shortest(6).rest() ++ ")", + if(empty, "(empty)"), + if(conflict, "(conflict)"), + if(divergent, "(divergent)"), + if(hidden, "(hidden)"), + if(immutable, "🔒"), + ) + ' + ''; + }; gitBugScript = pkgs.writeShellApplication { name = "git-bug-prompt"; runtimeInputs = [ @@ -71,23 +111,21 @@ "codeberg.org" = unicode "\\ue2a6"; "git.jojodev.com" = unicode "\\udb83\\udd9e"; "gitea.com" = unicode "\\udb83\\udd9e"; }; - disable_with_jj = true; }; style = "powerline"; + template = "{{ if not (glob \".jj\")}} {{ if .UpstreamURL }}{{ url .UpstreamIcon .UpstreamURL }} {{ end }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} ${unicode "\\uf044"} {{ .Working.String }}{{ end }}{{ if .Staging.Changed }} ${unicode "\\uf046"} {{ .Staging.String }}{{ end }} {{ end }}"; type = "git"; } { - type = "jujutsu"; - style = "powerline"; - powerline_symbol = ""; - foreground = "p:black"; background = "p:green"; - options = { - fetch_status = true; - ignore_working_copy = false; - fetch_ahead_counter = true; - ahead_icon = "⇡"; + foreground = "p:black"; + powerline_symbol = unicode "\\ue0b0"; + properties = { + script = "${jjScript}/bin/jj-prompt"; }; + style = "powerline"; + template = "{{ if (glob \".jj\")}} {{ .Output }} {{ end }}"; + type = "command"; } { background = "p:maroon";