Repository navigation
Description
Basics
- I have done a basic search through the issue tracker to find similar or related issues.
- I have made myself familiar with the available features of Nushell for the particular area this enhancement request touches.
Describe the solution you'd like
Oh My Posh has a feature called streaming: the prompt renders immediately, slow segments (git status in a large repo, a network call) show a placeholder, and the prompt updates in place as each segment resolves. It works today in PowerShell, zsh, fish, and cmd (Clink). We want to support it in Nushell, but Nushell has no way to update the prompt once the line editor is active.
How it works
Users set "streaming": 100 in their config: a per-segment budget in milliseconds. Segments that exceed it render a placeholder and keep executing; each completion re-renders the full prompt. The same setting enables a long-lived oh-my-posh serve daemon per shell session, which renders every prompt on request and spares the process spawn each time; a one-shot oh-my-posh stream process serves as fallback.
Both speak the same protocol: null-byte (\0) delimited records on stdout, each a complete, fully escaped prompt string, ready to display as-is. A \x1e prefix marks a transient-prompt record the shell caches for Enter. The daemon takes one JSON request per prompt ({"command":"render","id":42,...}, via stdin or a named pipe) and prefixes its records with the request id so the shell can drop stale ones; abort cancels an in-flight cycle, and losing its stdout pipe kills the daemon, so it dies with the shell.
The shell-side integration is thin. It must:
- Spawn and read: run the renderer in the background and read its stdout without blocking the REPL.
- Repaint on data: when a record arrives while the user sits at the prompt, replace the displayed prompt and repaint, preserving the edit buffer and cursor.
- Stop on accept: on Enter or Ctrl-C, stop consuming updates so a late record does not paint over command output.
Requirement 2 is the one Nushell lacks. The four supported shells each solve it with a native async primitive plus a buffer-preserving repaint call:
| Shell | Async notification | Repaint call |
|---|---|---|
| zsh | zle -F <fd> handler (fd watcher inside the line editor) |
set PS1, then zle reset-prompt |
| fish | background reader process signals the shell with SIGUSR1 |
set prompt variable, then commandline -f repaint |
| PowerShell | PowerShell.OnIdle engine event drains a shared queue |
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt() |
| cmd | Clink Lua coroutines poll the daemon | clink.refilterprompt() |
The cycle, with zsh as the reference:
sequenceDiagram
participant U as User
participant S as Shell (line editor)
participant O as oh-my-posh
S->>O: render request (status, duration, pwd, ...)
O-->>S: record 1: prompt with "..." placeholders
S->>U: display prompt
U->>S: starts typing
Note over O: git segment resolves after 400ms
O-->>S: record 2: full prompt, git segment filled in
Note over S: fd watcher fires (zle -F)
S->>S: PS1 = record 2, zle reset-prompt
Note over U: prompt updates in place,<br/>typed input untouched
O-->>S: record 3 (\x1e prefix): transient prompt
S->>S: cache transient prompt
U->>S: presses Enter
S->>S: stop updates,<br/>print cached transient prompt
S->>U: command executes
Where this touches the Nushell integration
Today's init script (oh-my-posh init nu) is fully synchronous:
$env.PROMPT_COMMAND = {|| _omp_get_prompt primary }
$env.PROMPT_COMMAND_RIGHT = {|| _omp_get_prompt right }_omp_get_prompt blocks until every segment has finished; a slow git repository holds the entire prompt hostage. This closure is where streaming slots in: request a render, return the first record, and let later records repaint. Everything else maps onto what Nushell already has: the daemon starts once at init and dies with its stdout pipe, the transient prompt uses $env.TRANSIENT_PROMPT_COMMAND, and the pre_execution hook covers stop-on-accept.
What Nushell is missing
Nushell evaluates $env.PROMPT_COMMAND once per prompt cycle and hands the result to reedline as static prompt content before read_line() starts. From then until the line is submitted, two things are impossible:
- Nothing external can wake the REPL.
job spawngives us a background thread that could read the records, but the main thread is parked insideread_line()and only processes key events. There is no fd watcher, timer, or job-message delivery that fires while the editor waits for input. - Prompt content cannot change mid-edit. Reedline has
ReedlineEvent::Repaint, and Nushell exposes it asevent: { send: repaint }in$env.config.keybindings, but only a keypress can trigger it, and when it fires, Nushell hands reedline the same stored string. Bind a key torepaintand press it mid-edit: the redraw is safe and buffer-preserving, yet the content never changes.
Reedline already contains most of the required plumbing: the ExternalPrinter is a channel that background threads write to; reedline polls it during read_line() and safely redraws (print above the prompt, restore the buffer). Asynchronous prompt updates need the same wake-and-redraw cycle, except the payload replaces the prompt instead of printing above it.
The ask
A mechanism for a background job to replace the prompt while read_line() is active, preserving the edit buffer and cursor. Two shapes would work, in order of preference:
Option A: push-based prompt updates (preferred). A way for a background job to hand the REPL a pre-rendered prompt string and trigger a repaint, such as a commandline set-prompt subcommand. Internally this could mirror the ExternalPrinter design: a channel polled in reedline's read_line() loop that updates the prompt content and repaints. Oh My Posh sends complete prompt strings, so nothing needs re-evaluation.
Option B: externally triggered prompt re-evaluation. A way for a background job to make Nushell re-run $env.PROMPT_COMMAND and repaint in place. This works too, but costs a closure evaluation per update and runs user code on the engine mid-edit.
With Option A, the integration would be roughly:
$env.PROMPT_COMMAND = {||
job spawn {
^$_omp_executable stream --shell=nu ...context...
| split row (char --integer 0) # \0 delimited records
| each {|record|
if ($record | str starts-with (char --integer 30)) {
$env._omp_transient = ($record | str substring 1..)
} else {
commandline set-prompt --left $record # <- the missing capability
}
}
}
# ... return the first record synchronously so the prompt shows instantly
}Everything except commandline set-prompt is expressible in Nushell today. The daemon variant has the same shape: the job holds oh-my-posh serve for the session, and PROMPT_COMMAND writes a render request per prompt.
Guarantees from our side
- Every record is a complete prompt string; applying only the latest one is always correct, so a slow consumer can coalesce updates and the shell never assembles or diffs anything.
- The renderer dies on SIGPIPE/EOF when the shell goes away; nothing to reap.
- On any failure the integration falls back to today's synchronous rendering, and users without
streamingin their config keep the exact current behavior.
We will build and maintain the Nushell side of the integration, as we do for the other shells, and adjust our protocol if a different API shape lands. One capability unblocks this, and likely every other async-prompt tool in the ecosystem (starship and friends share the limitation): let a background job replace the prompt and repaint while the line editor is active.
Activity
fdncred commentedon Jul 15, 2026
Hey @JanDeDobbeleer! Good to see you around here. There is this PR nushell/reedline#1117 that may eventually land. Do you think it will fulfill your needs?
JanDeDobbeleer commentedon Jul 15, 2026
@fdncred yup, this is the right foundation. The
RepaintSignalgives us exactly the wake-up we need, and the semantics fit our record protocol well: requests coalesce, stale requests get drained, and the repaint preserves the edit buffer.One piece is still missing, and I believe it lives in Nushell rather than in this PR. The repaint re-queries the
Prompttrait, butNushellPromptreturns the strings it stored beforeread_line()started, so a signal-triggered repaint redraws the same prompt (if my understanding is correct). A background job also has no way to reach the signal or to hand Nushell new content: jobs run on a cloned environment, so they cannot change anything the prompt reads.fdncred commentedon Jul 15, 2026
Thanks for your review of that PR. We'll look into it. I've wanted this for a long time too.
philocalyst commentedon Jul 15, 2026
I concur with @JanDeDobbeleer -- funny enough I started this work for a similar mechanism in Starship! Great to see competition in this space :)
Will review anything you and the oh-my-posh team put up on Nushell, seems like you have a very good direction for the PR!
JanDeDobbeleer commentedon Jul 15, 2026
@philocalyst just when I thought I beat you to it 😂 Best of luck on that one though, it's a tough one.
Feel free to take inspiration from my working implementation in shells that support it (I'm not saying it's perfect, this feature took 2 years to craft incrementally).
fdncred commentedon Jul 15, 2026
nushell/reedline#1117 landed! Let the nushell async prompt begin 😆
fdncred commentedon Aug 3, 2026
@JanDeDobbeleer Are you able to try this PR out #18660 on the latest main branch of nushell to see if it works for you?
JanDeDobbeleer commentedon Aug 4, 2026
@fdncred on it.
JanDeDobbeleer commentedon Aug 5, 2026
@fdncred this works, I'm just having another issue. Not sure why but nushell appears quite a bit slower to render the prompt compared to other shells. I'll try to launch an investigation of what happens, but at least this is functional with my custom build and adjusted script.
fdncred commentedon Aug 5, 2026
ok, thanks for the feedback. We'll look into performance too. It would be great to be able to experience what you've experienced so that we can test with your scenario. Can you share a little more about how to reproduce this performance issue @JanDeDobbeleer ?
async prompt updating (nushell#18660)
philocalyst commentedon Aug 5, 2026
@JanDeDobbeleer Apologies for the repeated pings, but what I would need to effectively enhance this are the following:
JanDeDobbeleer commentedon Aug 5, 2026
@philocalyst the problem isn't related to this feature, it seems to be something else. I'm doing an analysis, let it not stop this functionality from going live.