Files
TerminalPolyjuice/nushell/modules/pj_starship.nu
T
gwbeip deb4e45c4e fix(nushell): improve robustness and clarify abstraction boundaries
- pj_completions: merge into $env.config instead of replacing it wholesale
- pj_completions: use parse-time const for cache dir instead of pwd fallback
- pj_fzf / pj_historyhintcomplete: null-safe keybindings access via ? and default
- pj_helix: replace $env.OS (Windows-only) with $nu.os-info.name; extract shared launcher
- pj_prompt: fix off-by-one in git OID substring (0..7 -> 0..<7)
- pj_prompt: use $nu.os-info.name for OS detection instead of sys host hostname
- pj_prompt: cache git availability in static base, skip per-render which call
- pj_prompt: bind LAST_EXIT_CODE once in right-prompt closure
- pj_brew / pj_uv: add --ignore-errors to hide-env calls
- pj_aliases: convert quote/dadjoke to defs with try/catch error handling
- pj_deepseek: guard curl availability before invoking
- pj_zoxide: add ? to $nu.os-info.name access
- pj_starship: fix null-to-nuon producing "null" string; broaden detection
- nu_polyjuice: load pj_starship module
2026-07-31 00:31:04 +08:00

39 lines
1.8 KiB
Nu

export def --env "pj starship config" [name: string] {
if (which ^starship | is-empty) {
echo "starship is not installed."
return
}
let cfg = ($env.NU_POLYJUICE_PATH | path join ".." "starship" $"starship_($name).toml")
$env.STARSHIP_CONFIG = $cfg
}
export def --env "pj starship list" [] {
if (which ^starship | is-empty) {
echo "starship is not installed."
return
}
ls ($env.NU_POLYJUICE_PATH | path join ".." "starship") -s | get name | parse -r '^(starship_(?<name>.*).toml)$' | get name
}
export def "pj starship doctor" [] {
let installed = ((which ^starship | length) > 0)
let prompt_type = ($env.PROMPT_COMMAND? | describe)
let right_prompt_type = ($env.PROMPT_COMMAND_RIGHT? | describe)
let prompt_cmd = if ($env.PROMPT_COMMAND? == null) { "<not-set>" } else { ($env.PROMPT_COMMAND | to nuon --serialize) }
let right_prompt_cmd = if ($env.PROMPT_COMMAND_RIGHT? == null) { "<not-set>" } else { ($env.PROMPT_COMMAND_RIGHT | to nuon --serialize) }
let prompt_uses_starship = ($prompt_cmd | str contains "starship")
let right_prompt_uses_starship = ($right_prompt_cmd | str contains "starship")
{
starship_installed: $installed
starship_path: ((which ^starship | get path.0?) | default "<not-found>")
starship_version: (if $installed { (^starship --version | str trim) } else { "<not-installed>" })
STARSHIP_SHELL: ($env.STARSHIP_SHELL? | default "<not-set>")
STARSHIP_CONFIG: ($env.STARSHIP_CONFIG? | default "<not-set>")
prompt_command_type: $prompt_type
prompt_command_uses_starship: $prompt_uses_starship
prompt_command_right_type: $right_prompt_type
prompt_command_right_uses_starship: $right_prompt_uses_starship
}
}