new plugin: uniform status presentation in prompt for multiple vcs systems #604

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants

This plugin is designed to provide a uniform prompt status that
accommodates multiple vcs systems. The intent is to have reasonable
defaults for displaying each element of work tree status but also the
flexibility to make modifications without copying and pasting entire
functions into your own theme (or reimplementing a function just to
change one aspect of its behavior).

FEATURE HIGHLIGHTS

  • uniform PROMPT interface for multiple vcs types
    one addition to your PROMPT gets you all
  • supports git, hg, svn
  • indicators and (optional) counts for the primary dirty file types of
    each supported vcs (e.g. 1N 3A 2U for 1 new, 3 added, 2 untracked)
    • inspired by the git_status_prompt function from lib/git.zsh
      • rewritten as inline awk script to:
        • optionally include counts for each dirty type
        • provide more readable code
        • move towards more modular code to support more vcs systems
  • indicators for ahead-by and behind-by with counts; commits from
    upstream not yet merged or local commits not yet pushed,respectively
    (git-only for now)
  • dirt age indicator to show how long it has been since a
    significant action in the work tree (i.e. commit, file edited)
    • reworked git_time_since_commit function found in multiple themes
    • now centralized in a plugin
    • and generalized to support hg and svn
  • highly configurable, with many hooks for adding style information to
    each element
  • can rearrange order of elements
  • uses an associative array, VCS_PLUGIN, for (almost) all of its
    configuration settings
  • incorporates functionally equivalent replacements of all functions from
    from the git, svn, and hg oh-my-zsh plugins (but not any of their
    aliases)
  • handles ignored subdirectories of git work trees
Seth Milliken
new vcs prompt plugin
This plugin is designed to provide a uniform prompt status that
accommodates multiple vcs systems. The intent is to have reasonable
defaults for displaying each element of work tree status but also the
flexbility to make modifications without copying and pasting entire
functions into your own theme (or reimplementing a function just to
change one aspect of its behavior).

FEATURE HIGHLIGHTS
- uniform PROMPT interface for multiple vcs types
  one addition to your PROMPT gets you all
- supports git, hg, svn
- indicators and (optional) counts for the primary dirty file types of
  each supported vcs (e.g. `1N 3A 2U` for 1 new, 3 added, 2 untracked)
  - inspired by the `git_status_prompt` function from lib/git.zsh
    - rewritten as inline awk script to:
      - optionally include counts for each dirty type
      - provide more readable code
      - move towards more modular code to support more vcs systems
- indicators for ahead-by and behind-by with counts; commits from
  upstream not yet merged or local commits not yet pushed,respectively
  (git-only for now)
- dirt age indicator to show how long it has been since a
  significant action in the work tree (i.e. commit, file edited)
  - reworked `git_time_since_commit` function found in multiple themes
  - now centralized in a plugin
  - and generalized to support hg and svn
- highly configurable, with many hooks for adding style information to
  each element
- can rearrange order of elements
- uses an associative array, VCS_PLUGIN, for (almost) all of its
  configuration settings
- incorporates functionally equivalent replacments of all functions from
  from the git, svn, and hg oh-my-zsh plugins (but not any of their
  aliases)
- handles ignored subdirectories of git work trees

maybe you are interested in this feature for get status of git remotes

@juanpabloaj: ah, nice. i'll add that to my list for the next revision. and this serves as another reminder that i ought to reimplement the plumbing of this plugin to use vcs_info where possible, too.

Contributor

sorin-ionescu commented Sep 14, 2011

There is a built-in vcs_info that's quite flexible and has support for many version control systems.

The following themes use vcs_info.

  • jnrowe
  • kolo
  • linuxonly
  • mikeh
  • nicoulaj
  • steeef
  • trapd00r

@sorin-ionescu: i found vcs_info well into my efforts on this plugin. again, i had started from the incorrect assumption that the existing oh-my-zsh facilities were something-better-than-nothing and sought to improve them. i have already begun thinking about how to reimplement dirty file counts and staleness detection using vcs_info (the two primary innovations this plugin would offer to oh-my-zsh users in their themes; neither of which vcs_info appears to support natively, but which appear possible via vcs_info's hook mechanism).

Contributor

sorin-ionescu commented Sep 14, 2011

I have made silly duplications myself until I have decided to dive into the dreadful man zshall. It's how we learn.

In the effort to make #377 a reality, in my fork, I have rewritten the Git plugin and converted a few themes to the native ZSH theming system. Right now, we have a dedicated Git plugin and delegate all other version control systems to vcs_info via themes, and the people who need multiple version control systems can use one of those themes.

vcs_info, unfortunately, targets the lowest common denominator. People who need more that it provides can either use vcs_info hooks or clone the Git plugin to rewrite it to fit their VCS, and if that's the case, a vcs-info wrapper plugin around one or more VCS plugins is very easy to create.

if git-info && [[ -n "$git_prompt_info" ]] || [[ -n "$git_rprompt_info" ]]; then
  vcs_prompt_info="$git_prompt_info"
  vcs_rprompt_info="$git_rprompt_info"
elif hg-info && [[ -n "$hg_prompt_info" ]] || [[ -n "$hg_rprompt_info" ]]; then
  vcs_prompt_info="$hg_prompt_info"
  vcs_rprompt_info="$hg_rprompt_info"
else
  unset vcs_prompt_info
  unset vcs_rprompt_info
fi

In the theme file, one would replace the word 'git' with 'vcs', and it should just work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment