Skip to main content

PyGit2 implementation of the builtin gitstatus PROMPT fields.

xontrib-pygitstatus provides a set of PROMPT fields that mimic the behavior of the builtin gitstatus prompt fields with minor differences.

Unlike the builtin prompt, xontrib-pygitstatus does not invoke the git cli, so may be more performant in the following cases:

  • You're on a Windows workstations, where process spawning is slower than Linux
  • You have an on-access virtus scanner installed, which will slow down git cli invocations
  • Git is not installed on your system

Installation

To install use pip:

xpip install xontrib-pygitstatus
# or: xpip install -U git+https://github.com//xontrib-pygitstatus

Usage

This xontrib will get loaded automatically for interactive sessions. To stop this, set

$XONTRIBS_AUTOLOAD_DISABLED = ["pygitstatus", ]
# if you have set this for other xontribs, you should append the vale

then use pygitstatus's prompts in your .xonshrc file:

PROMPT = '{pygitstatus}'

Example modified default prompt:

$PROMPT = '{YELLOW}{env_name}{RESET}{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} {cwd}{pygitstatus.branch_color}{pygitstatus_curr_branch: {}}{RESET} {RED}{last_return_code_if_nonzero:[{BOLD_INTENSE_RED}{}{RED}] }{RESET}{BOLD_BLUE}{prompt_end}{RESET}'

Differences from gitstatus

PyGitStatus is a fork of gitstatus that nearly follows the same logic as the original gitstatus prompt, but with a few differences:

  • Conflict files are intentionally excluded from pygitstatus.staged.
  • The pygitstatus prompt will include conflicted files when both are added to the index and the working tree.

Fields

{pygitstatus}
{pygitstatus_curr_branch}
{pygitstatus.ahead}
{pygitstatus.behind}
{pygitstatus.branch}
{pygitstatus.branch_bg_color}
{pygitstatus.branch_color}
{pygitstatus.changed}
{pygitstatus.clean}
{pygitstatus.conflicts}
{pygitstatus.deleted}
{pygitstatus.lines_added}
{pygitstatus.lines_deleted}
{pygitstatus.numstat}
{pygitstatus.operations}
{pygitstatus.repo_path}
{pygitstatus.short_head}
{pygitstatus.staged}
{pygitstatus.stash_count}
{pygitstatus.tag}
{pygitstatus.tag_or_hash}
{pygitstatus.untracked}

Known issues

While this xontrib works on Windows, the tests do not pass on Windows.

Credits

This package was created with xontrib template.

Metadata

Release files for xontrib-pygitstatus 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xontrib-pygitstatus 0.1.0
File Size Uploaded
xontrib_pygitstatus-0.1.0.tar.gz 16.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xontrib-pygitstatus 0.1.0
File Interpreter ABI Platform
xontrib_pygitstatus-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.9 kB

Release files / xontrib_pygitstatus-0.1.0.tar.gz

Download URL xontrib_pygitstatus-0.1.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dce4a1ca90e76e97ef45e81f75747eb441b54cfb73963754d2865a3fcc5a4555
BLAKE2b-256 checksum
How to use checksums
9c1d5d3c325794d2cdbb88b615df400c005bd0974e17a170acc43275d1b6f5d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 1, 2025.

Transparency log

Release files / xontrib_pygitstatus-0.1.0-py3-none-any.whl

Download URL xontrib_pygitstatus-0.1.0-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2aa82a9fdeb962153dfb802356113d82a4604ee936d006e5421e1974964b72be
BLAKE2b-256 checksum
How to use checksums
844783b5862f15ac86bca5f5175c7d83c8714b27dd3242bcb9e30a02f4b4758e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 1, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page