1
0
Fork 0

polish ashleydev theme

pull/1/head
Ashley Dev 14 years ago
parent 9de97768c5
commit 369670184c

@ -1,9 +1,31 @@
#-------------------- PROMPT definition: ---------------------- #-------------------- PROMPT definition: ----------------------
# Set the prompt. # Set the prompt.
# 'R'eset formats # 'R'eset formating
local R="%{$terminfo[sgr0]%}" local R="%{$terminfo[sgr0]%}"
# special colors for privileged users (root)
local user_="%(!.%{$fg_bold[yellow]$bg[red]%}.%{$fg_bold[cyan]%})%n$R"
local host_="%(!.%{$fg[red]%}.%{$fg_bold[blue]%})%m$R"
local path_="%(!.%{$fg_bold[white]%}.%{$fg_bold[white]%})%~$R"
local jobs_="%(1j.%{$fg[blue]%}%j$R.)"
PROMPT='$user_$host_$path_ $(git_prompt_info)$jobs_# '
local date_format_="%D{%a %b %d}, %*"
local date_="%{$fg[green]%}[$date_format_]"
local return_code_="%(?..%{$fg[red]%}%? ↵ )"
RPROMPT='$return_code_$R$date_$R'
# use the vi-mode oh-my-zsh plugin to get this:
MODE_INDICATOR="%{$fg_bold[cyan]%}-- CMD MODE -- $R"
#-----------------------------------------------------
# git prompt info:
local GIT_PROMPT_SHOWUPSTREAM="verbose"
# git_prompt_info colors ('_C' for color): # git_prompt_info colors ('_C' for color):
local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory
local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo
@ -16,23 +38,122 @@ local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty
local _Cp_="%{${fg[cyan]}%}" # upstream info local _Cp_="%{${fg[cyan]}%}" # upstream info
local _Cs_="" # stash state local _Cs_="" # stash state
# will set __GIT_PROMPT_INFO
__git_prompt_format_and_color_with_shortcircuit ()
{
local g="$(__git_dir)"
if [ -z "$g" ]; then
__GIT_PROMPT_INFO=''
return
fi
# special colors for privileged users (root) local w="" # workspace state
local jobs_="%{$fg[blue]%}%(1j.%j.)" local s="" # stash state
local user_="%(!.%{$fg_bold[yellow]$bg[red]%}.%{$fg_bold[cyan]%})%n" local i="" # index state
local host_="%(!.%{$fg[red]%}.%{$fg_bold[blue]%})%m" local u="" # untracked files state
local path_="%(!.%{$fg_bold[white]%}.%{$fg_bold[white]%})%~" local p="" # u'p'stream state
local b="$(__git_branch)" # branch
local r="$(__git_rebase_info)" # rebase info
if [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
if [ "$GIT_PROMPT_SHOWDIRTYSTATE" != 'off' ]; then
if [ "$(git config --bool prompt.showDirtyState)" != "false" ]; then
# This is the short circuit logic:
# The following 3 functions can take a long time on big
# repositories, so check to see if ctrl-c is entered by
# setting _big_repo for the duration of these functions:
# (Then check for _big_repo in TRAPINT().)
_big_repo='yes'
i="$(__git_dirty_state_staged)"
w="$(__git_dirty_state_unstaged)"
u="$(__git_dirty_state_untracked_files)"
_big_repo=''
fi
fi
s="$(__git_stash_state)"
p="$(__git_upstream)"
fi
PROMPT='$user_$R$host_$R$path_$R $(git_prompt_info)$R$jobs_$R# ' if [ -z "$b$i$w$u" ]; then
if [ -n "$g" ]; then
__GIT_PROMPT_INFO="$R$_Cerror_(Error: bad ./$g dir)$R"
return
fi
fi
local date_format_="%D{%a %b %d}, %*" if [ "$s" = 'dirty' ]; then
local date_="%{$fg[green]%}[$date_format_]" s="$_Cs_\$$R"
local return_code_="%(?..%{$fg[red]%}%? ↵ )" else
s=""
fi
# use the vi-mode oh-my-zsh plugin to get this: if [ -n "$p" ]; then
MODE_INDICATOR="%{$fg_bold[cyan]%}-- CMD MODE -- $R" p="$_Cp_$p$R"
fi
RPROMPT='$return_code_$R$date_$R' if [ "$i" = "dirty" ]; then
i="$_Ci_+$R"
else
i=""
fi
if [ -n "$b" ]; then
if [ "$w" = "fresh" ]; then
# this is a fresh repo, nothing here...
b="$_Cb_new_repo_$b$R"
elif [ "$w" = 'dirty' ]; then
b="$_Cb_dirty_$b$R"
elif [ "$w" = 'clean' ]; then
b="$_Cb_clean_$b$R"
fi
fi
if [ -n "$r" ]; then
r="$_Cr_$r$R"
fi
local _prompt="$b$r$s$i$p"
# add ( ) around _prompt:
if [ "$u" = "dirty" ]; then
_prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)"
elif [ "$u" = "clean" ]; then
_prompt="$_Cu_clean_($_prompt$_Cu_clean_)"
else
_prompt="($_prompt)"
fi
# NOTE: This function must set __GIT_PROMPT_INFO to return it's value,
# rather than echo'ing it for the caller to call it as:
# __GIT_PROMPT_INFO=$(__git_prompt_format_and_color_with_shortcircuit)
# because if we were to call this function in $(...), then the short-circuit
# would not work because __git_prompt_format_and_color_with_shortcircuit
# would be executed in a sub shell and setting _big_repo='yes' would not set
# the same _big_repo as is in scope in TRAPINT().
__GIT_PROMPT_INFO="$R$_prompt$R"
}
local _big_repo='init'
TRAPINT()
{
if [[ "$_big_repo" == 'yes' ]]; then
_big_repo=''
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
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: git config prompt.showDirtyState false" > /dev/stderr
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: On big git repos it takes a long time to get info for your prompt." > /dev/stderr
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: To revert it, run:" > /dev/stderr
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]:$reset_color git config prompt.showDirtyState true" > /dev/stderr
echo '' > /dev/stderr
git config prompt.showDirtyState 'false'
__git_prompt_format_and_color_with_shortcircuit
fi
fi
return $(( 128 + $1 ))
}
#------------------ setting git_prompt_info (FAST) ------------------ #------------------ setting git_prompt_info (FAST) ------------------
# To get a fast prompt I borrowed from: # To get a fast prompt I borrowed from:
@ -41,25 +162,22 @@ RPROMPT='$return_code_$R$date_$R'
# This section sets up some functions that get called infrequently as possible # This section sets up some functions that get called infrequently as possible
# and therefore don't slow your prompt down as you are using zsh. # and therefore don't slow your prompt down as you are using zsh.
export GIT_PS1_SHOWUPSTREAM="verbose" git_prompt_info ()
export GIT_PS1_SHOWSTASHSTATE='yes'
export GIT_PS1_SHOWDIRTYSTATE='yes'
export GIT_PS1_SHOWUNTRACKEDFILES='yes'
function git_prompt_info ()
{ {
# some older versions of zsh don't have periodic_functions, so do the slow # some older versions of zsh don't have periodic_functions, so do the slow
# path if that's the case: # path if that's the case:
[[ $ZSH_VERSION = *\ 4.2* ]] && update_current_git_vars [[ $ZSH_VERSION = *\ 4.2* ]] && update_current_git_vars
echo "$__GIT_PROMPT_INFO"
echo $__GIT_PROMPT_INFO
} }
function update_current_git_vars() update_current_git_vars()
{ {
__GIT_PROMPT_INFO="$(__git_prompt_format_and_color_with_shortcircuit)" # sets __GIT_PROMPT_INFO:
__git_prompt_format_and_color_with_shortcircuit
} }
function precmd_update_git_vars() precmd_update_git_vars()
{ {
if [ -n "$__EXECUTED_GIT_COMMAND" ]; then if [ -n "$__EXECUTED_GIT_COMMAND" ]; then
update_current_git_vars update_current_git_vars
@ -67,7 +185,7 @@ function precmd_update_git_vars()
fi fi
} }
function preexec_update_git_vars () preexec_update_git_vars ()
{ {
case "$1" in case "$1" in
vim*) vim*)
@ -96,10 +214,10 @@ function preexec_update_git_vars ()
# Enable auto-execution of functions. # Enable auto-execution of functions.
typeset -ga preexec_functions typeset -Uga preexec_functions
typeset -ga precmd_functions typeset -Uga precmd_functions
typeset -ga chpwd_functions typeset -Uga chpwd_functions
typeset -ga periodic_functions typeset -Uga periodic_functions
# Append git functions needed for prompt. # Append git functions needed for prompt.
preexec_functions+='preexec_update_git_vars' preexec_functions+='preexec_update_git_vars'
@ -108,15 +226,13 @@ chpwd_functions+='update_current_git_vars'
PERIOD=15 PERIOD=15
periodic_functions+='update_current_git_vars' periodic_functions+='update_current_git_vars'
#------------------ git information utils ------------------ #------------------ git information utils ------------------
# To pull information out of git, I borrowed from: # To pull information out of git, I borrowed from:
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash # https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
# __gitdir accepts 0 or 1 arguments (i.e., location) # __git_dir accepts 0 or 1 arguments (i.e., location)
# returns location of .git repo # echos location of .git repo
__gitdir () __git_dir ()
{ {
if [ -z "${1-}" ]; then if [ -z "${1-}" ]; then
if [ -n "${__git_dir-}" ]; then if [ -n "${__git_dir-}" ]; then
@ -134,8 +250,36 @@ __gitdir ()
} }
# echos divergence from upstream # echos divergence from upstream
# used by GIT_PS1_SHOWUPSTREAM #
__git_show_upstream () # Usage:
#
# divergence="$(__git_upstream)"
#
# output format:
# A "<" indicates you are behind, ">" indicates you are ahead, "<>"
# indicates you have diverged, "=" indicates no divergence, and "" indicates
# there is no upstream or this feature is turned 'off' (see below).
#
# You can control behaviour by setting GIT_PROMPT_SHOWUPSTREAM to a
# space-separated list of values:
# off no output
# verbose show number of commits ahead/behind (+/-) upstream instead
# of using "<" and ">".
# legacy don't use the '--count' option available in recent
# versions of git-rev-list
# git always compare HEAD to @{upstream}
# svn always compare HEAD to your SVN upstream
# By default, __git_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_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_upstream ()
{ {
local key value local key value
local svn_remote svn_url_pattern count n local svn_remote svn_url_pattern count n
@ -145,12 +289,8 @@ __git_show_upstream ()
# get some config options from git-config # get some config options from git-config
while read key value; do while read key value; do
case "$key" in case "$key" in
prompt.showUpstream) prompt.showupstream*)
GIT_PS1_SHOWUPSTREAM="$value" GIT_PROMPT_SHOWUPSTREAM="$value"
if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
p=""
return
fi
;; ;;
svn-remote.*.url) svn-remote.*.url)
svn_remote=( "${svn_remote[@]}" $value ) svn_remote=( "${svn_remote[@]}" $value )
@ -158,11 +298,16 @@ __git_show_upstream ()
upstream=svn+git # default upstream is SVN if available, else git upstream=svn+git # default upstream is SVN if available, else git
;; ;;
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
GIT_PROMPT_SHOWUPSTREAM=$1
fi
# parse configuration values # parse configuration values
for option in ${GIT_PS1_SHOWUPSTREAM}; do for option in ${GIT_PROMPT_SHOWUPSTREAM}; do
case "$option" in case "$option" in
off) return ;;
git|svn) upstream="$option" ;; git|svn) upstream="$option" ;;
verbose) verbose=1 ;; verbose) verbose=1 ;;
legacy) legacy=1 ;; legacy) legacy=1 ;;
@ -195,7 +340,7 @@ __git_show_upstream ()
if git rev-list --left-right "$upstream"...HEAD >/dev/null 2>&1; then if git rev-list --left-right "$upstream"...HEAD >/dev/null 2>&1; then
behind="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^<' | wc -l | tr -d ' ' 2>/dev/null)" behind="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^<' | wc -l | tr -d ' ' 2>/dev/null)"
ahead="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^[^<]' | wc -l | tr -d ' ' 2>/dev/null)" ahead="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^[^<]' | wc -l | tr -d ' ' 2>/dev/null)"
count="$behind $ahead" count="$behind $ahead"
fi fi
# calculate the result # calculate the result
@ -203,11 +348,11 @@ __git_show_upstream ()
case "$count" in case "$count" in
"") # no upstream "") # no upstream
p="" ;; p="" ;;
"0 0") # equal to upstream "0 0") # equal to upstream
p="=" ;; p="=" ;;
"0 "*) # ahead of upstream "0 "*) # ahead of upstream
p=">" ;; p=">" ;;
*" 0") # behind upstream *" 0") # behind upstream
p="<" ;; p="<" ;;
*) # diverged from upstream *) # diverged from upstream
p="<>" ;; p="<>" ;;
@ -216,212 +361,175 @@ __git_show_upstream ()
case "$count" in case "$count" in
"") # no upstream "") # no upstream
p="" ;; p="" ;;
"0 0") # equal to upstream "0 0") # equal to upstream
p="=" ;; p="=" ;;
"0 "*) # ahead of upstream "0 "*) # ahead of upstream
p="+${count#0 }" ;; p="+${count#0 }" ;;
*" 0") # behind upstream *" 0") # behind upstream
p="-${count% 0}" ;; p="-${count% 0}" ;;
*) # diverged from upstream *) # diverged from upstream
p="-${count% *}+${count#* }" ;; p="-${count% *}+${count#* }" ;;
esac esac
fi fi
echo $p echo $p
} }
__git_show_rebase_info () __git_rebase_info ()
{ {
local r="" if [ "$GIT_PROMPT_SHOWREBASEINFO" != 'off' ]; then
local g="$(__gitdir)" if [ "$(git config --bool prompt.showRebaseInfo)" != "false" ]; then
if [ -n "$g" ]; then
if [ -f "$g/rebase-merge/interactive" ]; then local r=""
r="|REBASE-i" local g="$(__git_dir)"
elif [ -d "$g/rebase-merge" ]; then if [ -n "$g" ]; then
r="|REBASE-m" if [ -f "$g/rebase-merge/interactive" ]; then
else r="|REBASE-i"
if [ -d "$g/rebase-apply" ]; then elif [ -d "$g/rebase-merge" ]; then
if [ -f "$g/rebase-apply/rebasing" ]; then r="|REBASE-m"
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
else else
r="|AM/REBASE" if [ -d "$g/rebase-apply" ]; then
if [ -f "$g/rebase-apply/rebasing" ]; then
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
else
r="|AM/REBASE"
fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
r="|CHERRY-PICKING"
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
fi fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
r="|CHERRY-PICKING"
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi fi
echo $r
fi fi
fi fi
echo $r
} }
# stores the branch name in $b __git_branch ()
__git_show_branch ()
{ {
local b="" if [ "$GIT_PROMPT_SHOWBRANCH" != 'off' ]; then
local g="$(__gitdir)" if [ "$(git config --bool prompt.showBranch)" != "false" ]; then
if [ -n "$g" ]; then
if [ -f "$g/rebase-merge/interactive" ]; then local b=""
b="$(cat "$g/rebase-merge/head-name")" local g="$(__git_dir)"
elif [ -d "$g/rebase-merge" ]; then if [ -n "$g" ]; then
b="$(cat "$g/rebase-merge/head-name")" if [ -f "$g/rebase-merge/interactive" ]; then
else b="$(cat "$g/rebase-merge/head-name")"
b="$(git symbolic-ref HEAD 2>/dev/null)" || { elif [ -d "$g/rebase-merge" ]; then
b="$(cat "$g/rebase-merge/head-name")"
b="$( else
case "${GIT_PS1_DESCRIBE_STYLE-}" in b="$(git symbolic-ref HEAD 2>/dev/null)" || {
(contains)
git describe --contains HEAD ;; b="$(
(branch) case "${GIT_PROMPT_DESCRIBE_STYLE-}" in
git describe --contains --all HEAD ;; (contains)
(describe) git describe --contains HEAD ;;
git describe HEAD ;; (branch)
(* | default) git describe --contains --all HEAD ;;
git describe --tags --exact-match HEAD ;; (describe)
esac 2>/dev/null)" || git describe HEAD ;;
(* | default)
b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)" || git describe --tags --exact-match HEAD ;;
b="$b" esac 2>/dev/null)" ||
}
fi b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)" ||
b=${b##refs/heads/} b="$b"
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 fi
b="BARE:$b" b=${b##refs/heads/}
else if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
b="GIT_DIR!" if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
b="BARE:$b"
else
b="GIT_DIR!"
fi
fi
fi fi
echo $b
fi fi
fi fi
echo $b
} }
__git_show_untracked_files () __git_dirty_state_untracked_files ()
{ {
if [ -n "$(git ls-files --others --exclude-standard)" ]; then if [ "$GIT_PROMPT_SHOWUNTRACKEDFILES" != 'off' ]; then
echo "%" if [ "$(git config --bool prompt.showUntrackedFiles)" != "false" ]; then
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
echo ${GIT_PROMPT_SHOWUNTRACKEDFILES_DIRTY_MARK-dirty}
else
echo ${GIT_PROMPT_SHOWUNTRACKEDFILES_CLEAN_MARK-clean}
fi
return
fi
fi fi
echo ${GIT_PROMPT_FEATURE_OFF-feature_off}
} }
__git_show_stash_state ()
{
git rev-parse --verify refs/stash >/dev/null 2>&1 && echo "$"
}
__git_show_dirty_state_unstaged ()
{
git diff --no-ext-diff --quiet --exit-code || echo "*"
}
__git_show_dirty_state_staged () __git_stash_state ()
{ {
if git rev-parse --quiet --verify HEAD >/dev/null; then if [ "$GIT_PROMPT_SHOWSTASHSTATE" != 'off' ]; then
git diff-index --cached --quiet HEAD -- || echo "+" if [ "$(git config --bool prompt.showStashState)" != "false" ]; then
else if git rev-parse --verify refs/stash >/dev/null 2>&1; then
echo "#" echo ${GIT_PROMPT_SHOWSTASHSTATE_DIRTY_MARK-dirty}
else
echo ${GIT_PROMPT_SHOWSTASHSTATE_CLEAN_MARK-clean}
fi
return
fi
fi fi
echo ${GIT_PROMPT_FEATURE_OFF-feature_off}
} }
#-----------------------------------------------------
__git_prompt_format_and_color_with_shortcircuit ()
{
local g="$(__gitdir)"
if [ -n "$g" ]; then
local w="" # workspace state
local s="" # stash state
local i="" # index state
local si="" # stash + index state
local u="" # untracked files state
local p="" # u'p'stream state
local b="$(__git_show_branch)" # branch
local r="$(__git_show_rebase_info)" # rebase info
if [ -n "$r" ]; then
r="$_Crebase_$r$R"
fi
if [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then __git_dirty_state_unstaged ()
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then {
if [ "$(git config --bool prompt.showDirtyState)" != "false" ]; then if [ "$GIT_PROMPT_DIRTYSTATEUNSTAGED" != 'off' ]; then
if [ "$(git config --bool prompt.showDirtyStateUnstaged)" != "false" ]; then
if [ -z "$(eval print \$_big_repo$$)" ]; then if git rev-parse --quiet --verify HEAD >/dev/null; then
# This is the short circuit logic: if git diff --no-ext-diff --quiet --exit-code; then
# The following 3 functions can take a long time on big echo ${GIT_PROMPT_DIRTYSTATEUNSTAGED_CLEAN_MARK-clean}
# repositories, so check to see if ctrl-c is entered by else
# setting _big_repo$$ for the duration of these functions: echo ${GIT_PROMPT_DIRTYSTATEUNSTAGED_DIRTY_MARK-dirty}
eval _big_repo$$='yes'
i="$(__git_show_dirty_state_staged)"
if [ "$i" = "+" ]; then
i="$_Ci_$i$R"
fi
w="$(__git_show_dirty_state_unstaged)"
if [ -n "$b" ]; then
if [ "$i" = "#" ]; then
# this is a fresh repo, nothing here...
b="$_Cb_new_repo_$b$R"
i=''
elif [ -n "$w" ]; then
b="$_Cb_dirty_$b$R"
else
b="$_Cb_clean_$b$R"
fi
fi
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
u="$(__git_show_untracked_files)"
fi
else
echo "$fg[red]"
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: Looks like you hit ctrl-c."
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: On big repositories it takes a long time to get git info for your prompt."
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: So I'm setting \`git config prompt.showDirtyState false\` on this repository because you hit ctrl-c."
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: To revert it, run:"
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]:$reset_color git config prompt.showDirtyState true"
echo ''
git config prompt.showDirtyState 'false'
fi
unset _big_repo$$
fi fi
else
echo ${GIT_PROMPT_FRESH_REPO-fresh}
fi fi
return
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
s="$(__git_show_stash_state)"
fi
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
p="$(__git_show_upstream)"
fi
si="$i$s"
if [ -n "$s$p" ]; then
i+="$R"
p="$_Cp_$p$R"
s="$_Cs_$s$R"
fi
else
unset _big_repo$$
fi fi
fi
echo ${GIT_PROMPT_FEATURE_OFF-feature_off}
}
local _prompt="$b$r${si:+$i$s}$p" __git_dirty_state_staged ()
{
# add ( ) around _prompt: if [ "$GIT_PROMPT_DIRTYSTATESTAGED" != 'off' ]; then
if [ -z "$w$i$u$b" ]; then if [ "$(git config --bool prompt.showDirtyStateStaged)" != "false" ]; then
if [ -n "$g" ]; then if git rev-parse --quiet --verify HEAD >/dev/null; then
_prompt="$_Cerror_(Error: bad ./$g dir)" # if this isn't a fresh repo:
if git diff-index --cached --quiet HEAD --; then
echo ${GIT_PROMPT_DIRTYSTATESTAGED_CLEAN_MARK-clean}
else
echo ${GIT_PROMPT_DIRTYSTATESTAGED_DIRTY_MARK-dirty}
fi
else
# else take the slower route
local num_index_files="$(git status --porcelain | egrep '^[MADRCU]' | wc -l | tr -d ' ')"
if [ $num_index_files = 0 ]; then
echo ${GIT_PROMPT_DIRTYSTATESTAGED_CLEAN_MARK-clean}
else
echo ${GIT_PROMPT_DIRTYSTATESTAGED_DIRTY_MARK-dirty}
fi
fi fi
elif [ -n "$u" ]; then return
_prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)"
else
_prompt="$_Cu_clean_($_prompt$_Cu_clean_)"
fi fi
echo "$R$_prompt$R"
fi fi
echo ${GIT_PROMPT_FEATURE_OFF-feature_off}
} }

Loading…
Cancel
Save