summaryrefslogtreecommitdiffstats
path: root/common/commandline/starship.nix
blob: 98b6e3614f44e29aeb4e4cfbd68ee2b4f56ee351 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
_inputs:
{ lib, pkgs, ... }:
{
  users.extraUsers.minijackson.packages = [ pkgs.sd ];

  home-manager.sharedModules = [
    {
      programs.starship = {
        enable = true;
        enableZshIntegration = true;

        settings = lib.mkMerge [
          {
            directory = {
              fish_style_pwd_dir_length = 2;
              repo_root_style = "bold cyan";
              style = "bold white";
              truncate_to_repo = false;
            };

            hostname = {
              ssh_symbol = "ssh ";
              style = "bold blue";
            };

            jobs.symbol = "+ ";

            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)
        ];
      };
    }
  ];
}