git.prompt

index · git

Overview

Git repository status for shell prompt integration, built on the git core reader.

Provides prompt_status() which returns the status table shape used by the shell prompt git block: branch, tracking branch, tag (describe), staged/modified/untracked counts, ahead/behind.

Heavily cached: a per-cwd debounce cache, an mtime+content-validated git-state cache, and a gitignore rule cache.

Includes a gitignore matching engine for untracked-file counting.

Functions

NameSignature
configureconfigure(opts)
prompt_statusprompt_status(start_path) -> status
invalidate_prompt_cacheinvalidate_prompt_cache()

configure(opts)

Configure the git module's cache sizes and skip thresholds

Updates internal configuration from a table of options. Valid keys:

Unknown keys and type mismatches are silently ignored.

prompt_status(start_path) -> status

Get git repository status for shell prompt display

Returns a table with fields: branch, remote_branch, tag, staged, modified, untracked, ahead, behind, clean. Returns nil if not inside a git repository.

Results are debounced (at most one full computation per second) and internally cached by git-object mtimes. Call invalidate_prompt_cache() to force a fresh computation on the next call (e.g. after a command finishes).

invalidate_prompt_cache()

Clear the prompt_status debounce cache