Skip to main content

PyGit implementation of xonsh's builtin gitstatus PROMPT

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xontrib_pygitstatus-0.1.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xontrib_pygitstatus-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file xontrib_pygitstatus-0.1.0.tar.gz.

File metadata

  • Download URL: xontrib_pygitstatus-0.1.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for xontrib_pygitstatus-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dce4a1ca90e76e97ef45e81f75747eb441b54cfb73963754d2865a3fcc5a4555
MD5 83105a5ef3e3bcc9df1deb3b2074b898
BLAKE2b-256 9c1d5d3c325794d2cdbb88b615df400c005bd0974e17a170acc43275d1b6f5d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for xontrib_pygitstatus-0.1.0.tar.gz:

Publisher: release.yml on Spitfire1900/xontrib-pygitstatus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xontrib_pygitstatus-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xontrib_pygitstatus-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2aa82a9fdeb962153dfb802356113d82a4604ee936d006e5421e1974964b72be
MD5 b55d68ec0dac01ab69abd9abd028793d
BLAKE2b-256 844783b5862f15ac86bca5f5175c7d83c8714b27dd3242bcb9e30a02f4b4758e

See more details on using hashes here.

Provenance

The following attestation bundles were made for xontrib_pygitstatus-0.1.0-py3-none-any.whl:

Publisher: release.yml on Spitfire1900/xontrib-pygitstatus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page