Custom prompts
Build a custom Zsh prompt from NBSP_DATA while nobsprompt handles fast data collection, asynchronous refresh, and redraw.
Detached mode turns nbsp into a prompt-data backend for Zsh. It retains the
cache-only foreground path, asynchronous Git refresh, command timing, job
tracking, redraw correction, and external command editing. Your code owns
PROMPT and RPROMPT.
Use exactly one integration in a shell:
eval "$(nbsp init zsh --detached)"eval "$(nbsp init zsh)"The first mode initialized in a shell wins. Put initialization after NVM setup
so node_version reflects the active version.
Minimal prompt
Add this to ~/.zshrc:
eval "$(nbsp init zsh --detached)"
minimal_prompt() {
local path branch=
nbsp_prompt_escape "${NBSP_DATA[path]}"
path=$REPLY
if [[ ${NBSP_DATA[git_present]} == 1 ]]; then
nbsp_prompt_escape "${NBSP_DATA[git_branch]}"
branch=" [$REPLY]"
fi
PROMPT="${path}${branch} %# "
}
nbsp_data_update_functions+=(minimal_prompt)
minimal_prompt
The final call prepares the initial prompt. The registered callback rebuilds it after later data updates, including completed asynchronous Git refreshes.
Ownership boundary
Detached mode does not inspect, splice, or restore your prompt strings.
Your prompt code owns:
- colors and glyphs;
- one-line, multiline, and right-side layout;
- segment visibility and duration thresholds;
PROMPT_SUBST;- terminal title and other OSC wrappers.
The backend owns:
- collecting cache-safe prompt facts;
- command timing and job count;
- asynchronous Git refresh;
- atomic
NBSP_DATAreplacement; - update callbacks and ZLE redraw requests;
- external command editing.