{ pkgs, lib, config, ... }:
{
  programs.starship = {
    enable = true;
    enableBashIntegration = config.programs.bash.enable;
    # DOC: https://starship.rs/config/
    settings = {
      add_newline = false;
      command_timeout = 100;
      continuation_prompt = "[↳](bright-black) ";
      format = "$username$hostname$localip$shlvl$git_branch$git_commit$git_state$git_metrics$git_status$c$container$ocaml$purescript$nix_shell$haskell$memory_usage$sudo$cmd_duration$time$line_break$jobs$battery$directory$status$character";
      right_format = "";
      scan_timeout = 30;

      battery = {
        format = "[$symbol$percentage]($style) ";
        charging_symbol = " ";
        discharging_symbol = " ";
        empty_symbol = " ";
        full_symbol = " ";
        unknown_symbol = " ";
        disabled = false;
        display = [
          {
            style = "red bold";
            threshold = 50;
          }
        ];
      };
      character = {
        format = "$symbol ";
        vicmd_symbol = "[❮](bold green)";
        disabled = false;
        success_symbol = "[➜](bold green)";
        error_symbol = "[✗](bold red)";
      };
      cmd_duration = {
        min_time = 2000;
        format = "[($duration )]($style)";
        style = "bright-black bold";
        show_milliseconds = false;
        disabled = false;
        show_notifications = false;
        min_time_to_notify = 45000;
      };
      container = {
        format = "[$symbol [$name]]($style) ";
        symbol = "⬢";
        style = "red bold dimmed";
        disabled = false;
      };
      directory = {
        disabled = false;
        fish_style_pwd_dir_length = 0;
        format = "[$path]($style)[$read_only]($read_only_style) ";
        home_symbol = "~";
        #before_repo_root_style = "bold gray";
        #repo_root_style = "bold cyan";
        read_only = " RO";
        #read_only_style = "orange";
        #repo_root_format = "[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) ";
        style = "bold green";
        truncate_to_repo = true;
        truncation_length = 3;
        truncation_symbol = "…/";
        use_logical_path = true;
        use_os_path_sep = true;
      };
      directory.substitutions = {
        ## Here is how you can shorten some long paths by text replacement;
        ## similar to mapped_locations in Oh My Posh:;
        #"Documents" = " ";
        #"Downloads" = " ";
        #"Music" = " ";
        #"Pictures" = " ";
        ## Keep in mind that the order matters. For example:;
        ## "Important Documents" = "  ";
        ## will not be replaced, because "Documents" was already substituted before.;
        ## So either put "Important Documents" before "Documents" or use the substituted version:;
        ## "Important  " = "  ";
        #"Important " = " ";
      };
      env_var = { };
      env_var.SHELL = {
        format = "[$symbol($env_value )]($style)";
        style = "bright-black bold italic dimmed";
        symbol = "e:";
        disabled = true;
        variable = "SHELL";
        default = "unknown shell";
      };
      env_var.USER = {
        format = "[$symbol($env_value )]($style)";
        style = "bright-black bold italic dimmed";
        symbol = "e:";
        disabled = true;
        default = "unknown user";
      };
      fill = {
        style = "bold black";
        symbol = " ";
        disabled = false;
      };
      git_branch = {
        format = "[$symbol$branch(:$remote_branch)]($style) ";
        symbol = " ";
        style = "bold purple bg:0xFCA17D";
        truncation_length = 9223372036854775807;
        truncation_symbol = "…";
        only_attached = false;
        always_show_remote = false;
        ignore_branches = [ ];
        disabled = false;
      };
      git_commit = {
        commit_hash_length = 7;
        format = "[($hash$tag)]($style) ";
        style = "green bold";
        only_detached = true;
        disabled = false;
        tag_symbol = " 🏷  ";
        tag_disabled = true;
      };
      git_metrics = {
        added_style = "bold green";
        deleted_style = "bold red";
        only_nonzero_diffs = true;
        format = "([+$added]($added_style) )([-$deleted]($deleted_style) )";
        disabled = false;
      };
      git_state = {
        am = "AM";
        am_or_rebase = "AM/REBASE";
        bisect = "BISECTING";
        cherry_pick = "🍒PICKING(bold red)";
        disabled = false;
        format = "([$state( $progress_current/$progress_total)]($style)) ";
        merge = "MERGING";
        rebase = "REBASING";
        revert = "REVERTING";
        style = "bold yellow";
      };
      git_status = {
        format = "([$all_status( $ahead_behind)]($style) )";
        style = "purple bold";
        ahead = "⇡\${count}";
        diverged = "⇡\${ahead_count}⇣\${behind_count}";
        behind = "⇣\${count}";
        /*
        ahead = "🏎💨$count";
        behind = "😰$count";
        conflicted = "🏳";
        deleted = "🗑";
        disabled = false;
        diverged = "😵";
        format = "([$all_status$ahead_behind]($style) )";
        ignore_submodules = false;
        modified = "📝";
        renamed = "👅";
        staged = "[++($count)](green)";
        stashed = "📦";
        style = "red bold bg:0xFCA17D";
        untracked = "🤷";
        up_to_date = "✓";
        */
      };
      haskell = {
        format = "[$symbol($version )]($style)";
        version_format = "v$raw";
        symbol = "λ ";
        style = "yellow bold";
        disabled = false;
        detect_extensions = [
          "hs"
          "lhs"
          "cabal"
          "hs-boot"
        ];
        detect_files = [
          "stack.yaml"
          "cabal.project"
        ];
        detect_folders = [ ];
      };
      hostname = {
        disabled = false;
        format = "[$hostname]($style) ";
        ssh_only = true;
        style = "red dimmed bold";
        trim_at = ".";
      };
      jobs = {
        threshold = 1;
        symbol_threshold = 1;
        number_threshold = 1;
        format = "[$symbol$number]($style) ";
        symbol = "&";
        style = "yellow bold";
        disabled = false;
      };
      line_break = {
        disabled = false;
      };
      localip = {
        disabled = true;
        format = "[@$localipv4]($style) ";
        ssh_only = false;
        style = "yellow bold";
      };
      memory_usage = {
        disabled = true;
        format = "$symbol[$ram( | $swap)]($style) ";
        style = "white bold dimmed";
        symbol = " ";
        # threshold = 75;
        threshold = -1;
      };
      nix_shell = {
        format = "[$symbol]($style) ";
        #format = "[$symbol$state( \\($name\\))]($style)";
        disabled = false;
        impure_msg = "";
        #impure_msg = "[impure](bold red)";
        pure_msg = "[pure](bold green)";
        style = "bold blue";
        symbol = "❄️";
        #heuristic = true;
      };
      ocaml = {
        format = "[$symbol($version )(($switch_indicator$switch_name) )]($style)";
        global_switch_indicator = "";
        local_switch_indicator = "*";
        style = "bold yellow";
        symbol = "🐫 ";
        version_format = "v$raw";
        disabled = true;
        detect_extensions = [
          "opam"
          "ml"
          "mli"
          "re"
          "rei"
        ];
        detect_files = [
          "dune"
          "dune-project"
          "jbuild"
          "jbuild-ignore"
          ".merlin"
        ];
        detect_folders = [
          "_opam"
          "esy.lock"
        ];
      };
      purescript = {
        format = "[$symbol($version )]($style)";
        version_format = "v$raw";
        symbol = "<=> ";
        style = "bold white";
        disabled = true;
        detect_extensions = [ "purs" ];
        detect_files = [ "spago.dhall" ];
        detect_folders = [ ];
      };
      rlang = {
        format = "[$symbol($version )]($style)";
        version_format = "v$raw";
        style = "blue bold";
        symbol = "📐 ";
        disabled = true;
        detect_extensions = [
          "R"
          "Rd"
          "Rmd"
          "Rproj"
          "Rsx"
        ];
        detect_files = [ ".Rprofile" ];
        detect_folders = [ ".Rproj.user" ];
      };
      shlvl = {
        threshold = 2;
        format = "[$symbol$shlvl]($style) ";
        symbol = "↕️  ";
        repeat = false;
        style = "bold yellow";
        disabled = true;
      };
      status = {
        format = "[$symbol$status]($style) ";
        map_symbol = true;
        not_executable_symbol = "🚫";
        not_found_symbol = "🔍";
        pipestatus = false;
        pipestatus_format = "[$pipestatus] => [$symbol$common_meaning$signal_name$maybe_int]($style)";
        pipestatus_separator = "|";
        recognize_signal_code = true;
        signal_symbol = "⚡";
        style = "bold red bg:blue";
        success_symbol = "🟢 SUCCESS";
        symbol = "🔴 ";
        disabled = true;
      };
      sudo = {
        format = "[as $symbol]($style)";
        symbol = "🧙 ";
        style = "bold blue";
        allow_windows = false;
        disabled = true;
      };
      time = {
        format = "[\\[$time\\]]($style)";
        style = "bright-black bold";
        use_12hr = false;
        disabled = false;
        utc_time_offset = "local";
        # time_format = "%R"; # Hour:Minute Format;
        time_format = "%T"; # Hour:Minute:Seconds Format;
        time_range = "-";
      };
      username = {
        format = "[$user]($style) ";
        show_always = true;
        style_root = "red bold bg:0x9A348E";
        style_user = "bright-black bold bg:0x9A348E";
        disabled = false;
      };
      custom = { };
    };
  };
  programs.bash = {
    initExtra = ''
      function set_win_title(){
        echo -ne "\033]0;Term: $USER@$HOSTNAME: $PWD\007"
      }
      starship_precmd_user_func="set_win_title"
    '';
  };
}