mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2026-08-24 10:14:12 -05:00
93bc7953c10a046f202d8387ddc66195b943539e
* fix: streaming placeholder not updated when async is enabled
When both async and streaming are configured on ZSH, the init command
becomes 'precmd() { source <script> }', which re-sources the script on
every prompt cycle. This unconditionally reset _omp_stream_fd=-1, causing
_omp_cleanup_stream to skip closing the previous cycle's stream fd.
The stale stream's EOF handler would later call _omp_cleanup_stream using
the global _omp_stream_fd (now pointing to the new stream's fd) and kill
the new stream before it could send any updates. The placeholder never
got replaced.
Three fixes:
1. init.go: Skip async sourcing when streaming is also active. Streaming
provides its own async update mechanism; re-sourcing on every precmd is
not needed and conflicts with the streaming fd lifecycle.
2. omp.zsh (_omp_stream_fd init): Use \ so a
re-source does not clobber an in-flight stream fd.
3. omp.zsh (_omp_async_handler): On EOF, close only the specific fd that
triggered the handler instead of calling _omp_cleanup_stream. This
prevents any stale handler from closing the current stream's fd even if
the global variable has diverged.
Fixes #7313
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(zsh): streaming placeholder not updated when async is enabled
When both async and streaming are configured in ZSH, the omp.zsh script
is re-sourced before every prompt cycle via the async init mechanism
(precmd() { source <script> }). Top-level variable assignments in the
re-sourced script run unconditionally, so _omp_stream_fd was reset to -1
on every prompt cycle even while a live stream was in flight.
This caused two problems:
1. _omp_cleanup_stream skipped cleanup (fd -1 < 0) before starting the
new stream, leaking the old fd and its ZLE handler.
2. The stale EOF handler later fired, saw _omp_stream_fd pointing at the
NEW stream, and closed it so the placeholder was never replaced.
Fix 1: use _omp_stream_fd=\ (ZSH := modifier) so
the fd value survives a re-source, initialising to -1 only when the
variable is genuinely unset (first source at shell startup).
Fix 2: in _omp_async_handler, guard the EOF cleanup with
[[ \ -eq \ ]] so a stale handler from a previous
prompt cycle can never close the current stream's fd.
Reverts the init.go change from the previous commit changing the
async sourcing mechanism is unnecessary and caused a regression (exit
code 127) when streaming was enabled.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(zsh): correct misleading comment on stream fd initialization
The comment referenced := (ZSH assign-if-unset) but the code uses :-
(use-default-if-unset). Update the comment to accurately describe
what the expansion does.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This repo was made with love using GitKraken.
Sponsors
Join the community
What started as the offspring of oh-my-posh2 for PowerShell resulted in a cross platform, highly customizable and extensible prompt theme engine. After 4 years of working on oh-my-posh, a modern and more efficient tool was needed to suit my personal needs.
❤️ Support ❤️
- Show your love with a t-shirt!
- One time support, or a recurring donation?
Features
- Shell and platform agnostic
- Easily configurable
- The most configurable prompt utility
- Fast
- Secondary prompt
- Right prompt
- Transient prompt
Documentation
Reviews
Thanks
- Chris Benti providing the first influence to start oh-my-posh
- Keith Dahlby for creating posh-git and making life more enjoyable
- Robby Russell for creating oh-my-zsh, without him this would probably not be here
- Janne Mareike Koschinski for providing information on how to get certain information using Go (and the amazing README)
- Starship for doing great things
Description
The most customisable and low-latency cross platform/shell prompt renderer
bashcmdfishfish-shellgitgolanghacktoberfestnerd-fontsnushellpowerlinepowershellpromptprompt-toolkitshell-promptstarshiptooltipszsh
Readme
159 MiB
Languages
Go
66.1%
MDX
19.2%
JavaScript
9%
PowerShell
2%
Shell
1.7%
Other
1.7%

