PROMPT_ASYNC(1)

NAME

prompt_async - return cached prompt command output and refresh it in the background.

SYNOPSIS

prompt_async key --ttl milliseconds -- command...

DESCRIPTION

prompt_async is for prompt data that may be slow to compute, such as Git state. It returns cached standard output immediately. If the cache is missing or older than the requested TTL, Rush starts command as a hidden refresh and returns the old cached value, or nothing if no value has been cached yet.

When the hidden command exits, Rush automatically requests a safe prompt redraw. The next prompt render sees the fresh cached stdout. Prompt configuration does not need to call prompt repaint after prompt_async.

Cache entries are keyed by the current directory plus key. Duplicate refreshes for the same cache entry are coalesced. Standard error from hidden refreshes is suppressed, and refreshes do not change the interactive shell's last status.

EXAMPLE

git_branch="$(prompt_async git-branch --ttl 5000 -- git branch --show-current)"
if test "$git_branch" != ""; then
  prompt segment --fg yellow "$git_branch"
fi

EXIT STATUS

Zero when a cached value is returned or a refresh is started, and two for usage errors. Hidden command failures do not directly become the status of prompt_async.

SEE ALSO

rush-builtins(7), prompt(1), prompt_pwd(1), rush configuration.