# Starship integration (inlined from `starship init nu`)
$env.STARSHIP_SHELL = "nu"
$env.STARSHIP_SESSION_KEY = (random chars -l 16)
$env.PROMPT_MULTILINE_INDICATOR = (^starship prompt --continuation)
$env.PROMPT_INDICATOR = ""
$env.PROMPT_COMMAND = {||
    let cmd_duration = if $env.CMD_DURATION_MS == "0823" { 0 } else { $env.CMD_DURATION_MS }
    (^starship prompt
        --cmd-duration $cmd_duration
        $"--status=($env.LAST_EXIT_CODE)"
        --terminal-width (term size).columns
        ...(
            if (which "job list" | where type == built-in | is-not-empty) {
                ["--jobs", (job list | length)]
            } else { [] }
        )
    )
}
$env.PROMPT_COMMAND_RIGHT = {||
    let cmd_duration = if $env.CMD_DURATION_MS == "0823" { 0 } else { $env.CMD_DURATION_MS }
    (^starship prompt
        --right
        --cmd-duration $cmd_duration
        $"--status=($env.LAST_EXIT_CODE)"
        --terminal-width (term size).columns
        ...(
            if (which "job list" | where type == built-in | is-not-empty) {
                ["--jobs", (job list | length)]
            } else { [] }
        )
    )
}
$env.config = ($env.config | merge { render_right_prompt_on_last_line: true })

# Vi mode indicators — Starship does not handle these for Nu
$env.PROMPT_INDICATOR_VI_INSERT = $"  (ansi { fg: '{{- if eq .chezmoi.config.data.theme "apex-neon" }}#00ff99{{- else }}#00b377{{- end }}' })❯(ansi reset) "
$env.PROMPT_INDICATOR_VI_NORMAL = $"  (ansi { fg: '{{- if eq .chezmoi.config.data.theme "apex-neon" }}#ffb700{{- else }}#d18f00{{- end }}' })❮(ansi reset) "
$env.TRANSIENT_PROMPT_COMMAND = $"(ansi { fg: '#737373' })❯(ansi reset) "
$env.TRANSIENT_PROMPT_INDICATOR_VI_INSERT = ""
$env.TRANSIENT_PROMPT_INDICATOR_VI_NORMAL = ""
