From 89d003440abcbf060c6f3234430f74d78f3aa328 Mon Sep 17 00:00:00 2001 From: "s0wlz (Matthias Puchstein)" Date: Tue, 19 May 2026 02:30:09 +0200 Subject: [PATCH] added starship to nu --- dot_config/nushell/prompt.nu.tmpl | 42 +++++++++--- dot_config/starship.toml.tmpl | 110 ++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 10 deletions(-) create mode 100644 dot_config/starship.toml.tmpl diff --git a/dot_config/nushell/prompt.nu.tmpl b/dot_config/nushell/prompt.nu.tmpl index a780ded..655b402 100644 --- a/dot_config/nushell/prompt.nu.tmpl +++ b/dot_config/nushell/prompt.nu.tmpl @@ -1,16 +1,38 @@ +# 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 dir = ($env.PWD | str replace $env.HOME "~") - let branch = (try { ^git rev-parse --abbrev-ref HEAD err> /dev/null | str trim } catch { "" }) - let dirty = (try { - if (^git status --porcelain err> /dev/null | str trim | is-empty) { "" } else { "*" } - } catch { "" }) - - let git_seg = if ($branch | is-empty) { "" } else { - $" (ansi { fg: '{{- if eq .chezmoi.config.data.theme "apex-neon" }}#00ff99{{- else }}#00b377{{- end }}' })($branch)(ansi { fg: '#ff0044' })($dirty)(ansi reset)" - } - $"(ansi { fg: '{{- if eq .chezmoi.config.data.theme "apex-neon" }}#00eaff{{- else }}#007a88{{- end }}' })($dir)(ansi reset)($git_seg)" + 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) " diff --git a/dot_config/starship.toml.tmpl b/dot_config/starship.toml.tmpl new file mode 100644 index 0000000..d440fab --- /dev/null +++ b/dot_config/starship.toml.tmpl @@ -0,0 +1,110 @@ +# ─── Top-level settings (must appear before any [section] headers) ───────────── +palette = "{{ .chezmoi.config.data.theme }}" +add_newline = false +format = "$directory$git_branch$git_status$python$nodejs$rust$golang$docker_context" +right_format = "$cmd_duration$status$time" + +# ─── Palettes ──────────────────────────────────────────────────────────────── +[palettes.apex-neon] +void = "#050505" +text = "#ededed" +dim = "#737373" +razor = "#ff0044" +tech = "#00eaff" +toxic = "#00ff99" +amber = "#ffb700" +azure = "#0088cc" +sacred = "#9d00ff" + +[palettes.apex-aeon] +void = "#f5f5f5" +text = "#0a0a0a" +dim = "#737373" +razor = "#ff0044" +tech = "#007a88" +toxic = "#00b377" +amber = "#d18f00" +azure = "#005577" +sacred = "#7a3cff" + +# ─── Character — disabled, vi mode handled by Nu PROMPT_INDICATOR_VI_* ──────── +[character] +disabled = true + +# ─── Directory ─────────────────────────────────────────────────────────────── +[directory] +style = "bold fg:tech" +truncation_length = 4 +truncate_to_repo = true +format = "[$path]($style)" +home_symbol = "~" + +# ─── Git ───────────────────────────────────────────────────────────────────── +# Branch: space · branch-name (trailing space creates gap before git_status) +[git_branch] +style = "fg:tech" +symbol = "" +format = " [·](fg:dim) [$branch]($style) " + +# Status: compact symbols, no leading space needed (git_branch provides it) +[git_status] +style = "fg:razor" +format = "([$all_status$ahead_behind]($style))" +conflicted = "✖" +ahead = "↑${count}" +behind = "↓${count}" +diverged = "⇕↑${ahead_count}↓${behind_count}" +untracked = "?" +stashed = "≡" +modified = "✦" +staged = "+" +renamed = "»" +deleted = "✗" + +# ─── Language versions — dim, abbreviated, separator-prefixed ──────────────── +[python] +style = "fg:dim" +format = "( [·](fg:dim) [py $version]($style))" +version_format = "${major}.${minor}" +detect_files = ["pyproject.toml", "Pipfile", "requirements.txt", ".python-version", "setup.py", "uv.lock"] + +[nodejs] +style = "fg:dim" +format = "( [·](fg:dim) [node $version]($style))" +version_format = "${major}" + +[rust] +style = "fg:dim" +format = "( [·](fg:dim) [rs $version]($style))" +version_format = "${major}.${minor}" + +[golang] +style = "fg:dim" +format = "( [·](fg:dim) [go $version]($style))" +version_format = "${major}.${minor}" + +[docker_context] +style = "fg:dim" +format = "( [·](fg:dim) [󰡨 $context]($style))" +only_with_files = true + +# ─── Right prompt ──────────────────────────────────────────────────────────── +[cmd_duration] +min_time = 2_000 +style = "fg:amber" +format = "[$duration]($style) " +show_milliseconds = false + +[status] +disabled = false +format = "[$symbol]($style)" +symbol = "✗" +success_symbol = "✓" +style = "bold fg:razor" +success_style = "bold fg:toxic" + +[time] +disabled = false +style = "fg:dim" +format = " [$time]($style)" +time_format = "%H:%M"