|
|
|
@ -18,7 +18,7 @@
|
|
|
|
|
#
|
|
|
|
|
# # this is a simple example PROMPT with only git
|
|
|
|
|
# # info from this plugin in it:
|
|
|
|
|
# PROMPT='$__GIT_PROMPT_INFO# '
|
|
|
|
|
# PROMPT='$_GIT_PROMPT_INFO# '
|
|
|
|
|
#
|
|
|
|
|
# #GIT_PROMPT_SHORTCIRCUIT='off'
|
|
|
|
|
#
|
|
|
|
@ -27,29 +27,29 @@
|
|
|
|
|
# # in order to turn this plugin on.
|
|
|
|
|
# GIT_PROMPT_INFO_FUNC='update__GIT_PROMPT_INFO'
|
|
|
|
|
#
|
|
|
|
|
# local __GIT_PROMPT_INFO=''
|
|
|
|
|
# local _GIT_PROMPT_INFO=''
|
|
|
|
|
# update__GIT_PROMPT_INFO ()
|
|
|
|
|
# {
|
|
|
|
|
# _git_prompt__branch
|
|
|
|
|
# git_prompt__branch
|
|
|
|
|
# local b=$GIT_PROMPT_BRANCH
|
|
|
|
|
#
|
|
|
|
|
# _git_prompt__dirty_state
|
|
|
|
|
# git_prompt__dirty_state
|
|
|
|
|
# local w=$GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY
|
|
|
|
|
# local i=$GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY
|
|
|
|
|
#
|
|
|
|
|
# # Reset color
|
|
|
|
|
# local R="%{$terminfo[sgr0]%}"
|
|
|
|
|
#
|
|
|
|
|
# if [ "$i" = "yes" ]; then
|
|
|
|
|
# if [[ "$i" = "yes" ]]; then
|
|
|
|
|
# i="%{$bold_color$fg[red]%}+$R"
|
|
|
|
|
# else
|
|
|
|
|
# i=""
|
|
|
|
|
# fi
|
|
|
|
|
#
|
|
|
|
|
# if [ -n "$b" ]; then
|
|
|
|
|
# if [ "$w" = 'yes' ]; then
|
|
|
|
|
# if [[ -n "$b" ]]; then
|
|
|
|
|
# if [[ "$w" = 'yes' ]]; then
|
|
|
|
|
# b="%{$fg_no_bold[red]%}$b$R"
|
|
|
|
|
# elif [ "$w" = 'no' ]; then
|
|
|
|
|
# elif [[ "$w" = 'no' ]]; then
|
|
|
|
|
# b="%{$fg_no_bold[green]%}$b$R"
|
|
|
|
|
# fi
|
|
|
|
|
# fi
|
|
|
|
@ -66,18 +66,18 @@
|
|
|
|
|
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# _git_prompt__git_dir accepts 0 or 1 arguments (i.e., location)
|
|
|
|
|
# git_prompt__git_dir accepts 0 or 1 arguments (i.e., location)
|
|
|
|
|
# echos the location of .git repo.
|
|
|
|
|
# Useful for quickly figuring out if cwd is under a git repo.
|
|
|
|
|
_git_prompt__git_dir ()
|
|
|
|
|
git_prompt__git_dir ()
|
|
|
|
|
{
|
|
|
|
|
if [ -z "${1-}" ]; then
|
|
|
|
|
if [ -d .git ]; then
|
|
|
|
|
if [[ -z "${1-}" ]]; then
|
|
|
|
|
if [[ -d .git ]]; then
|
|
|
|
|
echo .git
|
|
|
|
|
else
|
|
|
|
|
git rev-parse --git-dir 2>/dev/null
|
|
|
|
|
fi
|
|
|
|
|
elif [ -d "$1/.git" ]; then
|
|
|
|
|
elif [[ -d "$1/.git" ]]; then
|
|
|
|
|
echo "$1/.git"
|
|
|
|
|
else
|
|
|
|
|
echo "$1"
|
|
|
|
@ -100,21 +100,21 @@ _git_prompt__git_dir ()
|
|
|
|
|
# versions of git-rev-list
|
|
|
|
|
# git always compare HEAD to @{upstream}
|
|
|
|
|
# svn always compare HEAD to your SVN upstream
|
|
|
|
|
# By default, _git_prompt__upstream will compare HEAD to your SVN upstream
|
|
|
|
|
# By default, git_prompt__upstream will compare HEAD to your SVN upstream
|
|
|
|
|
# if it can find one, or @{upstream} otherwise. Once you have
|
|
|
|
|
# set GIT_PROMPT_SHOWUPSTREAM, you can override it on a
|
|
|
|
|
# per-repository basis by setting the prompt.showUpstream config
|
|
|
|
|
# variable (i.e. `git config prompt.showUpstream 'verbose legacy'`).
|
|
|
|
|
#
|
|
|
|
|
# _git_prompt__upstream accepts 0 or 1 arguments. If an argument is given, it
|
|
|
|
|
# git_prompt__upstream accepts 0 or 1 arguments. If an argument is given, it
|
|
|
|
|
# must be a string of the form specified above for GIT_PROMPT_SHOWUPSTREAM.
|
|
|
|
|
# Setting this argument will override any value set for GIT_PROMPT_SHOWUPSTREAM
|
|
|
|
|
# or in the .git/config.
|
|
|
|
|
_git_prompt__upstream ()
|
|
|
|
|
git_prompt__upstream ()
|
|
|
|
|
{
|
|
|
|
|
GIT_PROMPT_UPSTREAM_STATE=''
|
|
|
|
|
|
|
|
|
|
if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
|
|
|
|
|
if [[ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -137,7 +137,7 @@ _git_prompt__upstream ()
|
|
|
|
|
esac
|
|
|
|
|
done < <(git config --get-regexp '^(svn-remote\..*\.url|prompt\.showupstream)' 2>/dev/null)
|
|
|
|
|
|
|
|
|
|
if [ -n "${1-}" ]; then
|
|
|
|
|
if [[ -n "${1-}" ]]; then
|
|
|
|
|
GIT_PROMPT_SHOWUPSTREAM=$1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -214,41 +214,41 @@ _git_prompt__upstream ()
|
|
|
|
|
|
|
|
|
|
# sets GIT_PROMPT_REBASE_INFO
|
|
|
|
|
# with info about a rebase/merge/etc if it's in progress.
|
|
|
|
|
_git_prompt__rebase_info ()
|
|
|
|
|
git_prompt__rebase_info ()
|
|
|
|
|
{
|
|
|
|
|
GIT_PROMPT_REBASE_INFO=''
|
|
|
|
|
|
|
|
|
|
if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
|
|
|
|
|
if [[ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
if [ "$GIT_PROMPT_SHOWREBASEINFO" = 'off' ]; then
|
|
|
|
|
if [[ "$GIT_PROMPT_SHOWREBASEINFO" = 'off' ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
if [ "$(git config --bool prompt.showRebaseInfo)" = "false" ]; then
|
|
|
|
|
if [[ "$(git config --bool prompt.showRebaseInfo)" = "false" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local r=""
|
|
|
|
|
local g="$(_git_prompt__git_dir)"
|
|
|
|
|
if [ -n "$g" ]; then
|
|
|
|
|
if [ -f "$g/rebase-merge/interactive" ]; then
|
|
|
|
|
local g="$(git_prompt__git_dir)"
|
|
|
|
|
if [[ -n "$g" ]]; then
|
|
|
|
|
if [[ -f "$g/rebase-merge/interactive" ]]; then
|
|
|
|
|
r="|REBASE-i"
|
|
|
|
|
elif [ -d "$g/rebase-merge" ]; then
|
|
|
|
|
elif [[ -d "$g/rebase-merge" ]]; then
|
|
|
|
|
r="|REBASE-m"
|
|
|
|
|
else
|
|
|
|
|
if [ -d "$g/rebase-apply" ]; then
|
|
|
|
|
if [ -f "$g/rebase-apply/rebasing" ]; then
|
|
|
|
|
if [[ -d "$g/rebase-apply" ]]; then
|
|
|
|
|
if [[ -f "$g/rebase-apply/rebasing" ]]; then
|
|
|
|
|
r="|REBASE"
|
|
|
|
|
elif [ -f "$g/rebase-apply/applying" ]; then
|
|
|
|
|
elif [[ -f "$g/rebase-apply/applying" ]]; then
|
|
|
|
|
r="|AM"
|
|
|
|
|
else
|
|
|
|
|
r="|AM/REBASE"
|
|
|
|
|
fi
|
|
|
|
|
elif [ -f "$g/MERGE_HEAD" ]; then
|
|
|
|
|
elif [[ -f "$g/MERGE_HEAD" ]]; then
|
|
|
|
|
r="|MERGING"
|
|
|
|
|
elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
|
|
|
|
|
elif [[ -f "$g/CHERRY_PICK_HEAD" ]]; then
|
|
|
|
|
r="|CHERRY-PICKING"
|
|
|
|
|
elif [ -f "$g/BISECT_LOG" ]; then
|
|
|
|
|
elif [[ -f "$g/BISECT_LOG" ]]; then
|
|
|
|
|
r="|BISECTING"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -260,27 +260,27 @@ _git_prompt__rebase_info ()
|
|
|
|
|
|
|
|
|
|
# sets GIT_PROMPT_BRANCH
|
|
|
|
|
# with the branch name
|
|
|
|
|
_git_prompt__branch ()
|
|
|
|
|
git_prompt__branch ()
|
|
|
|
|
{
|
|
|
|
|
GIT_PROMPT_BRANCH=''
|
|
|
|
|
|
|
|
|
|
if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
|
|
|
|
|
if [[ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$GIT_PROMPT_SHOWBRANCH" = 'off' ]; then
|
|
|
|
|
if [[ "$GIT_PROMPT_SHOWBRANCH" = 'off' ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
if [ "$(git config --bool prompt.showBranch)" = "false" ]; then
|
|
|
|
|
if [[ "$(git config --bool prompt.showBranch)" = "false" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local b=""
|
|
|
|
|
local g="$(_git_prompt__git_dir)"
|
|
|
|
|
if [ -n "$g" ]; then
|
|
|
|
|
if [ -f "$g/rebase-merge/interactive" ]; then
|
|
|
|
|
local g="$(git_prompt__git_dir)"
|
|
|
|
|
if [[ -n "$g" ]]; then
|
|
|
|
|
if [[ -f "$g/rebase-merge/interactive" ]]; then
|
|
|
|
|
b="$(cat "$g/rebase-merge/head-name")"
|
|
|
|
|
elif [ -d "$g/rebase-merge" ]; then
|
|
|
|
|
elif [[ -d "$g/rebase-merge" ]]; then
|
|
|
|
|
b="$(cat "$g/rebase-merge/head-name")"
|
|
|
|
|
else
|
|
|
|
|
b="$(git symbolic-ref HEAD 2>/dev/null)" || {
|
|
|
|
@ -302,8 +302,8 @@ _git_prompt__branch ()
|
|
|
|
|
}
|
|
|
|
|
fi
|
|
|
|
|
b=${b##refs/heads/}
|
|
|
|
|
if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
|
|
|
|
|
if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
|
|
|
|
|
if [[ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]]; then
|
|
|
|
|
if [[ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]]; then
|
|
|
|
|
b="BARE:$b"
|
|
|
|
|
else
|
|
|
|
|
b="GIT_DIR!"
|
|
|
|
@ -317,18 +317,18 @@ _git_prompt__branch ()
|
|
|
|
|
|
|
|
|
|
# sets GIT_PROMPT_STASH_STATE_DIRTY
|
|
|
|
|
# if the git stash state is dirty
|
|
|
|
|
_git_prompt__stash ()
|
|
|
|
|
git_prompt__stash ()
|
|
|
|
|
{
|
|
|
|
|
GIT_PROMPT_STASH_STATE_DIRTY=''
|
|
|
|
|
|
|
|
|
|
if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
|
|
|
|
|
if [[ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$GIT_PROMPT_SHOWSTASHSTATE" = 'off' ]; then
|
|
|
|
|
if [[ "$GIT_PROMPT_SHOWSTASHSTATE" = 'off' ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
if [ "$(git config --bool prompt.showStashState)" = "false" ]; then
|
|
|
|
|
if [[ "$(git config --bool prompt.showStashState)" = "false" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -380,7 +380,7 @@ __git_prompt_shortcircuit ()
|
|
|
|
|
{
|
|
|
|
|
if [[ "$_big_repo" == 'yes' ]]; then
|
|
|
|
|
_big_repo=''
|
|
|
|
|
if [ "$GIT_PROMPT_SHORTCIRCUIT" != 'off' ]; then
|
|
|
|
|
if [[ "$GIT_PROMPT_SHORTCIRCUIT" != 'off' ]]; then
|
|
|
|
|
echo "$fg[red]" > /dev/stderr
|
|
|
|
|
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: Looks like you hit ctrl-c." > /dev/stderr
|
|
|
|
|
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: So for this repo I'm setting:" > /dev/stderr
|
|
|
|
@ -402,7 +402,7 @@ TRAPINT ()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# sets a bunch of variables, see below:
|
|
|
|
|
_git_prompt__dirty_state ()
|
|
|
|
|
git_prompt__dirty_state ()
|
|
|
|
|
{
|
|
|
|
|
GIT_PROMPT_DIRTY_STATE_FRESH_REPO=''
|
|
|
|
|
GIT_PROMPT_DIRTY_STATE_INDEX_ADDED=''
|
|
|
|
@ -417,18 +417,18 @@ _git_prompt__dirty_state ()
|
|
|
|
|
GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED=''
|
|
|
|
|
GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED=''
|
|
|
|
|
|
|
|
|
|
if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
|
|
|
|
|
if [[ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local g="$(_git_prompt__git_dir)"
|
|
|
|
|
if [ -z "$g" ]; then
|
|
|
|
|
local g="$(git_prompt__git_dir)"
|
|
|
|
|
if [[ -z "$g" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
if [ "$GIT_PROMPT_SHOWDIRTYSTATE" = 'off' ]; then
|
|
|
|
|
if [[ "$GIT_PROMPT_SHOWDIRTYSTATE" = 'off' ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
if [ "$(git config --bool prompt.showDirtyState)" = "false" ]; then
|
|
|
|
|
if [[ "$(git config --bool prompt.showDirtyState)" = "false" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -523,7 +523,7 @@ _git_prompt__precmd_update_git_vars()
|
|
|
|
|
# slow path if that's the case:
|
|
|
|
|
$GIT_PROMPT_INFO_FUNC
|
|
|
|
|
|
|
|
|
|
elif [ -n "$__EXECUTED_GIT_COMMAND" ]; then
|
|
|
|
|
elif [[ -n "$__EXECUTED_GIT_COMMAND" ]]; then
|
|
|
|
|
$GIT_PROMPT_INFO_FUNC
|
|
|
|
|
unset __EXECUTED_GIT_COMMAND
|
|
|
|
|
fi
|
|
|
|
|