{
  lib,
  config,
  ...
}: let
  inherit (lib) mkDefault;

  cfg = config.marleyos.programs.starship;
in {
  config = lib.mkIf cfg.enable {
    programs.starship.settings = with config.lib.stylix.colors.withHashtag; let
      mkFormat = t: " [](fg:${base02})[${t}]($style)[](fg:${base02}) ";
      langFormat = mkFormat "$symbol$version";
    in {
      format = mkDefault (lib.concatStrings [
        "$username"
        "$hostname"
        "$directory"
        "$nix_shell"
        "$git_branch"
        "$git_status"
        "$fill"
        "$c"
        "$elixir"
        "$elm"
        "$golang"
        "$haskell"
        "$java"
        "$julia"
        "$nodejs"
        "$nim"
        "$rust"
        "$scala"
        "$python"
        "$time"
        "$line_break"
        "$character"
      ]);

      username = {
        disabled = mkDefault false;
        format = mkDefault " [](fg:${base02})[ 󰧱 $user@]($style)";
        show_always = mkDefault true;
        style_root = mkDefault "bg:${base02} fg:${base0D}";
        style_user = mkDefault "bg:${base02} fg:${base0D}";
      };

      hostname = {
        ssh_only = mkDefault false;
        format = mkDefault "[$hostname ]($style)[](fg:${base02}) ";
        style = mkDefault "bg:${base02} fg:${base0D}";
      };

      directory = {
        format = mkDefault (mkFormat " $path ");
        style = mkDefault "bg:${base02} fg:${base0B}";
        truncation_length = mkDefault 3;
        truncation_symbol = mkDefault "…/";

        substitutions = {
          Documents = mkDefault "󰈙";
          Downloads = mkDefault " ";
          Music = mkDefault " ";
          Pictures = mkDefault " ";
        };
      };

      git_branch = {
        format = mkDefault (mkFormat " $symbol $branch ");
        style = mkDefault "bg:${base02} fg:${base0C}";
        symbol = mkDefault "";
      };

      git_status = {
        disabled = mkDefault false;
        style = mkDefault "bg:${base02} fg:${base08}";
        format = mkDefault (mkFormat "$all_status$ahead_behind");
        up_to_date = mkDefault "[ ✓ ](bg:${base02} fg:${base0D})";
        untracked = mkDefault "[?\\($count\\)](bg:${base02} fg:${base09})";
        stashed = mkDefault "[\\$](bg:${base02} fg:${base0D})";
        modified = mkDefault "[!\\($count\\)](bg:${base02} fg:${base09})";
        renamed = mkDefault "[»\\($count\\)](bg:${base02} fg:${base0D})";
        deleted = mkDefault "[✘\\($count\\)](style)";
        staged = mkDefault "[++\\($count\\)](bg:${base02} fg:${base09})";
        ahead = mkDefault "[⇡\\(\${count}\\)](bg:${base02} fg:${base0C})";
        diverged = mkDefault "⇕[\\[](bg:${base02} fg:${base0D})[⇡\\(\${ahead_count}\\)](bg:${base02} fg:${base0C})[⇣\\(\${behind_count}\\)](bg:${base02} fg:${base0A})[\\]](bg:${base02} fg:${base0D})";
        behind = mkDefault "[⇣\\(\${count}\\)](bg:${base02} fg:${base0A})";
      };

      fill = {
        style = mkDefault "fg:${base02}";
        symbol = mkDefault " ";
      };

      time = {
        disabled = mkDefault false;
        format = mkDefault (mkFormat " $time 󰴈 ");
        style = mkDefault "bg:${base02} fg:${base0A}";
        time_format = mkDefault "%I:%M%P";
        use_12hr = mkDefault true;
      };

      character = let
        vim = "";
        mkChar = sym: col: " [${sym}](fg:${col}) [󰄾](fg:${base0C})";
      in {
        success_symbol = mkChar "" "${base0D}";
        error_symbol = mkChar "󰋔" "${base08}";
        vimcmd_symbol = mkChar vim "${base0A}";
        vimcmd_replace_one_symbol = mkChar vim "${base0C}";
        vimcmd_replace_symbol = mkChar vim "${base0C}";
        vimcmd_visual_symbol = mkChar vim "${base0D}";
      };

      ### Languages ###
      c = {
        style = mkDefault "bg:${base02} fg:${base0B}";
        format = mkDefault langFormat;
        disabled = mkDefault false;
        symbol = mkDefault " ";
      };

      elixir = {
        style = mkDefault "bg:${base02} fg:${base0B}";
        format = mkDefault langFormat;
        disabled = mkDefault false;
        symbol = mkDefault " ";
      };

      elm = {
        style = mkDefault "bg:${base02} fg:${base0B}";
        format = mkDefault langFormat;
        disabled = mkDefault false;
        symbol = mkDefault " ";
      };

      haskell = {
        style = mkDefault "bg:${base02} fg:${base0B}";
        format = mkDefault langFormat;
        disabled = mkDefault false;
        symbol = mkDefault " ";
      };

      java = {
        style = mkDefault "bg:${base02} fg:${base0B}";
        format = mkDefault langFormat;
        disabled = mkDefault false;
        symbol = mkDefault " ";
      };

      julia = {
        style = mkDefault "bg:${base02} fg:${base0B}";
        format = mkDefault langFormat;
        disabled = mkDefault false;
        symbol = mkDefault " ";
      };

      nodejs = {
        style = mkDefault "bg:${base02} fg:${base0B}";
        format = mkDefault langFormat;
        disabled = mkDefault false;
        symbol = mkDefault "󰎙 ";
      };

      nim = {
        style = mkDefault "bg:${base02} fg:${base0B}";
        format = mkDefault langFormat;
        disabled = mkDefault false;
        symbol = mkDefault "󰆥 ";
      };

      python = {
        style = mkDefault "bg:${base02} fg:${base0B}";
        disabled = mkDefault false;
        symbol = mkDefault " ";
      };

      rust = {
        style = mkDefault "bg:${base02} fg:${base0B}";
        format = mkDefault langFormat;
        disabled = mkDefault false;
        symbol = mkDefault "";
      };

      scala = {
        style = "bg:${base02} fg:${base0B}";
        format = mkDefault langFormat;
        disabled = false;
        symbol = " ";
      };

      ### Tools ###
      conda = {
        style = mkDefault "bg:${base02} fg:${base0B}";
        format = mkDefault (mkFormat "$symbol$environment");
        disabled = mkDefault false;
        symbol = mkDefault "🅒 ";
      };

      nix_shell = {
        style = "bg:${base02} fg:${base0C}";
        format = mkDefault (mkFormat " $symbol $state( \($name\)) ");
        disabled = mkDefault false;
        symbol = mkDefault " ";
      };
    };
  };
}
