diff --git a/share/functions/fish_git_prompt.fish b/share/functions/fish_git_prompt.fish index a72f2e21a..bc49fb40a 100644 --- a/share/functions/fish_git_prompt.fish +++ b/share/functions/fish_git_prompt.fish @@ -1,178 +1,10 @@ # based off of the git-prompt script that ships with git +# hence licensed under GPL version 2 (like the rest of fish). # -# Written by Kevin Ballard -# Updated by Brian Gernhardt +# Written by Lily Ballard and updated by Brian Gernhardt and fish contributors # -# This is heavily based off of the git-prompt.bash script that ships with -# git, which is Copyright (C) 2006,2007 Shawn O. Pearce . -# The act of porting the code, along with any new code, are Copyright (C) 2012 -# Kevin Ballard . -# -# By virtue of being based on the git-prompt.bash script, this script is -# distributed under the GNU General Public License, version 2.0. -# -# This script includes a function fish_git_prompt which takes a format string, -# exactly how the bash script works. This can be used in your fish_prompt -# function. -# -# The behavior of fish_git_prompt is very heavily based off of the bash -# script's __git_ps1 function. As such, usage and customization is very -# similar, although some extra features are provided in this script. -# Due to differences between bash and fish, the PROMPT_COMMAND style where -# passing two or three arguments causes the function to set PS1 is not -# supported. More information on the additional features is found after the -# bash-compatable documentation. -# -# The argument to fish_git_prompt will be displayed only if you are currently -# in a git repository. The %s token will be the name of the branch. -# -# In addition, if you set __fish_git_prompt_showdirtystate to a nonempty value, -# unstaged (*) and staged (+) changes will be shown next to the branch name. -# You can configure this per-repository with the bash.showDirtyState variable, -# which defaults to true once __fish_git_prompt_showdirtystate is enabled. The -# choice to leave the variable as 'bash' instead of renaming to 'fish' is done -# to preserve compatibility with existing configured repositories. -# -# You can also see if currently something is stashed, by setting -# __fish_git_prompt_showstashstate to a nonempty value. If something is -# stashed, then a '$' will be shown next to the branch name. -# -# If you would like to see if there are untracked files, then you can set -# __fish_git_prompt_showuntrackedfiles to a nonempty value. If there are -# untracked files, then a '%' will be shown next to the branch name. Once you -# have set __fish_git_prompt_showuntrackedfiles, you can override it on a -# per-repository basis by setting the bash.showUntrackedFiles config variable. -# As before, this variable remains named 'bash' to preserve compatibility. -# -# If you would like to see the difference between HEAD and its upstream, set -# __fish_git_prompt_showupstream to 'auto'. A "<" indicates you are behind, ">" -# indicates you are ahead, "<>" indicates you have diverged and "=" indicates -# that there is no difference. You can further control behavior by setting -# __fish_git_prompt_showupstream to a space-separated list of values: -# -# verbose show number of commits ahead/behind (+/-) upstream -# name if verbose, then also show the upstream abbrev name -# informative similar to verbose, but shows nothing when equal (fish only) -# git always compare HEAD to @{upstream} -# svn always compare HEAD to your SVN upstream -# none disables (fish only, useful with show_informative_status) -# -# By default, fish_git_prompt will compare HEAD to your SVN upstream if it -# can find one, or @{upstream} otherwise. Once you have set -# __fish_git_prompt_showupstream, you can override it on a per-repository basis -# by setting the bash.showUpstream config variable. As before, this variable -# remains named 'bash' to preserve compatibility. -# -# If you would like to see more information about the identity of commits -# checked out as a detached HEAD, set __fish_git_prompt_describe_style to -# one of the following values: -# -# contains relative to newer annotated tag (v1.6.3.2~35) -# branch relative to newer tag or branch (master~4) -# describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f) -# default exactly matching tag -# -# If you would like a colored hint about the current dirty state, set -# __fish_git_prompt_showcolorhints. The default colors are -# based on the colored output of "git status -sb" - - -# fish_git_prompt includes some additional features on top of the -# above-documented bash-compatible features: -# -# -# An "informative git prompt" mode similar to the scripts for bash and zsh -# can be activated by setting __fish_git_prompt_show_informative_status -# This works more like the "informative git prompt" scripts for bash and zsh, -# giving prompts like (master↑1↓2|●3✖4✚5…6) where master is the current branch, -# you have 1 commit your upstream doesn't and it has 2 you don't, and you have -# 3 staged, 4 unmerged, 5 dirty, and 6 untracked files. If you have no -# changes, it displays (master|✔). -# -# Setting __fish_git_prompt_show_informative_status changes several defaults. -# The default mode for __fish_git_prompt_showupstream changes to informative -# and the following characters have their defaults changed. (The characters -# and colors can still be customized as described below.) -# -# upstream_prefix () -# upstream_ahead (↑) -# upstream_behind (↓) -# stateseparator (|) -# dirtystate (✚) -# invalidstate (✖) -# stagedstate (●) -# untrackedfiles (…) -# stashstate (⚑) -# cleanstate (✔) -# -# -# The color for each component of the prompt can specified using -# __fish_git_prompt_color_, where is one of the following and the -# values are specified as arguments to `set_color`. The variable -# __fish_git_prompt_color is used for any component that does not have an -# individual color set. -# -# prefix Anything before %s in the format string -# suffix Anything after %s in the format string -# bare Marker for a bare repository -# merging Current operation (|MERGING, |REBASE, etc.) -# branch Branch name -# flags Optional flags (see below) -# upstream Upstream name and flags (with showupstream) -# -# -# The following optional flags have both colors, as above, and custom -# characters via __fish_git_prompt_char_. The default character is -# shown in parenthesis. The default color for these flags can be also be set -# via the __fish_git_prompt_color_flags variable. -# -# __fish_git_prompt_showdirtystate -# dirtystate unstaged changes (*) -# stagedstate staged changes (+) -# invalidstate HEAD invalid (#, colored as stagedstate) -# -# __fish_git_prompt_showstashstate -# stashstate stashed changes ($) -# -# __fish_git_prompt_showuntrackedfiles -# untrackedfiles untracked files (%) -# -# __fish_git_prompt_showupstream (all colored as upstream) -# upstream_equal Branch matches upstream (=) -# upstream_behind Upstream has more commits (<) -# upstream_ahead Branch has more commits (>) -# upstream_diverged Upstream and branch have new commits (<>) -# -# __fish_git_prompt_show_informative_status -# (see also the flags for showdirtystate and showuntrackedfiles, above) -# cleanstate Working directory has no changes (✔) -# -# -# The separator between the branch name and flags can also be customized via -# __fish_git_prompt_char_stateseparator. It can only be colored by -# __fish_git_prompt_color. It normally defaults to a space ( ) and defaults -# to a vertical bar (|) when __fish_git_prompt_show_informative_status is set. -# -# The separator before the upstream information can be customized via -# __fish_git_prompt_char_upstream_prefix. It is colored like the rest of -# the upstream information. It normally defaults to nothing () and defaults -# to a space ( ) when __fish_git_prompt_showupstream contains verbose. -# -# -# Turning on __fish_git_prompt_showcolorhints changes the colors as follows to -# more closely match the behavior in bash. Note that setting any of these -# colors manually will override these defaults. -# -# branch Defaults to green -# branch_detached New color, when head is detached, default red -# dirtystate Defaults to red -# stagedstate Defaults to green -# flags Defaults to --bold blue -# -# -# The branch name could be shorten via -# __fish_git_prompt_shorten_branch_len. Define the branch max len. -# __fish_git_prompt_shorten_branch_char_suffix. Customize suffixed char of shorten branch. Defaults to (…). +# This is based on git's git-prompt.bash script, Copyright (C) 2006,2007 Shawn O. Pearce . +# The act of porting the code, along with any new code, are Copyright (C) 2012 Lily Ballard. function __fish_git_prompt_show_upstream --description "Helper function for fish_git_prompt" set -l show_upstream $__fish_git_prompt_showupstream