aboutsummaryrefslogtreecommitdiff
path: root/modules/terminal/hjem/programs/starship.nix
blob: 7f537d9f4528366d147992039b807269d796d90f (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
{
  pkgs,
  lib,
  config,
  ...
}: let
  cfg = config.collinux.terminal.programs.starship;

  settings = {
    format = ''$directory$git_branch$git_status $character'';

    add_newline = false;
    scan_timeout = 10;

    character = {
      success_symbol = "[λ](green bold)";
      error_symbol = "[Σ](red bold)";
    };

    git_branch.format = "[@$branch](underline)";

    git_status = {
      format = "$modified$staged$ahead$behind";
      modified = "[!](red bold)";
      staged = "[+](green bold)";
      ahead = "[/](green)";
      behind = "[\](red)";
    };

    directory = {
      format = "$path";
      truncation_length = 3;
      truncate_to_repo = true;
    };
  };
in
  lib.mkIf cfg.enable {
    files =
      {
        ".config/starship.toml" = {
          generator = (pkgs.formats.toml {}).generate "starship.toml";
          value = settings;
        };
      }
      // (lib.optionalAttrs config.collinux.terminal.shells.fish.enable {
        ".config/fish/conf.d/starship.fish".text = ''
          function starship_transient_prompt_func
            starship module character
          end

          starship init fish | source
          enable_transience
        '';
      });

    packages = [pkgs.starship];
  }