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