{ options, config, lib, pkgs, ... }:

let inherit (lib.modules) mkIf;
in {
  options.modules.shell.toolset.starship =
    let inherit (lib.options) mkEnableOption;
    in { enable = mkEnableOption "minimal shell ricing"; };

  config = mkIf config.modules.shell.toolset.starship.enable {
    hm.programs.starship = {
      enable = true;
      settings = let inherit (config.modules.themes.colors.main) normal types;
      in {
        scan_timeout = 10;
        add_newline = true;
        line_break.disabled = true;

        format = ''
          [ÓÇ∂$directoryÓÇ¥](fg:${normal.yellow}) ($git_branch)($git_status )($nix_shell)
          ($character)'';
        # right_format = "[ÓÇ∂$cmd_durationÓÇ¥](bg:none fg:${normal.magenta})";

        cmd_duration = {
          min_time = 1;
          format = "[Ôâí $duration]($style)";
          disabled = false;
          style = "bg:${normal.magenta} fg:${types.bg}";
        };

        directory = {
          format = "[ÔÅª  $path]($style)";
          style = "bg:${normal.yellow} fg:${types.bg} bold";
          truncation_length = 2;
          truncation_symbol = "‚Ä¶/";
        };

        git_branch = {
          format =
            "[[ÓÇ∂](fg:${types.border})(Óú• $branch)[ÓÇ¥](fg:${types.border})]($style) ";
          style = "bg:${types.border} fg:${types.bg} bold";
        };

        git_status = {
          format =
            "[([ÓÇ∂](fg:${normal.blue})(ÔÑì „Äé $all_status$ahead_behind „Äè)[ÓÇ¥](fg:${normal.blue}))]($style)";
          style = "bg:${normal.blue} fg:${types.bg} bold";
        };

        character = {
          error_symbol = "[ÔÄç](${normal.red})";
          success_symbol = "[ÔÅî](${normal.green})";
          vicmd_symbol = "[Óò´](${normal.blue})";
        };

        nix_shell = {
          disabled = false;
          impure_msg = "[impure](${normal.red})";
          pure_msg = "[pure](${normal.green})";
          format = "via [$symbol$state( \\($name\\))]($style) ";
          style = "${normal.blue}";
          symbol = "[Œª ](${normal.blue})";
        };

        battery = {
          full_symbol = "üîã";
          charging_symbol = "‚ö°Ô∏è";
          discharging_symbol = "üíÄ";
          display = [{
            style = "${normal.red}";
            threshold = 15;
          }];
        };
      };
    };
  };
}
