A Zsh function that defers command execution until Zsh is idle, enabling staged startup for faster prompt display.
zsh-defer is a Zsh function that defers the execution of commands until Zsh is idle and waiting for user input. It solves the problem of slow shell startup by allowing heavy plugins and scripts to load in the background after the prompt appears, significantly improving perceived performance.
Zsh users who experience slow shell startup times, particularly those using multiple plugins or heavy initialization scripts and who want to keep their prompt responsive.
Developers choose zsh-defer for its simplicity, speed, and plugin-manager-agnostic design, offering Turbo-mode-like deferred execution without locking them into a specific ecosystem.
Deferred execution of Zsh commands
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The core is only about 150 lines of straightforward Zsh code, making it easy to audit, modify, and integrate without bloat.
Sources in under 1 millisecond, adding almost no delay to shell initialization, as confirmed by the README's benchmarks.
Works with any Zsh plugin manager or none, offering flexibility for diverse setups without locking users into a specific ecosystem.
Provides options like output redirection, hook calls, and prompt refreshing, allowing fine-tuned deferred loading to mitigate side effects.
Supports fractional second delays with the -t flag, enabling staged loading without blocking the Zsh line editor.
Deferred commands cannot read from stdin, preventing the use of interactive prompts or commands that require user input during loading.
Some plugins may fail when sourced from zle, as they aren't designed for deferred execution, potentially leading to breakage or requiring workarounds.
Executes commands in function scope with LOCAL_OPTIONS, which can interfere with scripts that set global variables or traps without the -g flag.