fish-shell/fish-shell — pull request #1757 by lloeki (2014-10-14 10:12:03+00:00)
Title: Git info functions and prompt

Info functions are split out from the prompt function because:

- it's evaluated once, ant it's evaluated efficiently
- it can be used in either (left) prompt or right prompt functions
- it's useful outside the prompt (scripts)
- it allows for fixing and evolving git stuff without breaking the user's
prompt on updates
- IOW it separates concerns of state evaluation and actual use of this
state, whether for display or for scripting

Some vars control advanced but potentially time-consuming behavior on
some big repos, so be sure to set those vars universally or globally,
depending on your use case:

set -U GIT_INFO_SHOWDIRTYSTATE 1
set -U GIT_INFO_SHOWSTASHSTATE 1
set -U GIT_INFO_SHOWUNTRACKEDFILES 1

Unset the vars to disable again.

A few examples are provided, as a prompt, and in comments, when one can
see how trivial it is to build his own prompt, from color to position to
symbols and simply leveraging the shell syntax to compose information,
all wihout introducting boatloads of non-composable variables that only
grant limited skin behavior.

Some path and context variables are interesting, such as
`GIT_INFO_BRANCH`, `GIT_INFO_SUBJECT`, `GIT_INFO_TOPLEVEL`, `GIT_INFO_NAME`, and
`GIT_INFO_PREFIX`, that allow one to easily build a prompt with various
segments of information, absolute or relative to a repo's root.