1
0
Fork 0

Change the api to use PROMPT='$GIT_PROMPT_INFO# ' instead of PROMPT='$(git_prompt_info)# '

pull/2/head
Ashley Dev 14 years ago
parent 459ebef612
commit b33e6b6598

@ -16,13 +16,29 @@
# (See the ashleydev theme for more complex usage.) # (See the ashleydev theme for more complex usage.)
# ---------------------- SAMPLE THEME FILE ------------------------ # ---------------------- SAMPLE THEME FILE ------------------------
# #
# # this is a simple example PROMPT with only git # # GIT_PROMPT_INFO_FUNC has to be set to the function that updates the
# # info from this plugin in it: # # global GIT_PROMPT_INFO variable(s). The GIT_PROMPT_INFO_FUNC function
# PROMPT='$(git_prompt_info2)# ' # # should be run whenever your prompt should be updated, but no more. This
# # means it won't slow down your prompt when you're doing things that won't
# # change the git info in your prompt.
# #
# # So setting GIT_PROMPT_INFO_FUNC both turns on this plugin on and allows
# # you to set up your own custom git_prompt_format_* function.
# #
# GIT_PROMPT_INFO_FUNC=git_prompt_info_default
# #
# # if you want to override the default format you can define your own # # git_prompt_info_default() will set $GIT_PROMPT_INFO, use this variable
# # _git_prompt_info() function that sets $_GIT_PROMPT_INFO with your format # # in your prompt:
# _git_prompt_info () # PROMPT='$GIT_PROMPT_INFO# '
#
# ---------------------- SAMPLE THEME FILE 2 ----------------------
# # If you want to override the default format you can define your own
# # format function:
# GIT_PROMPT_INFO_FUNC=git_prompt_format_simple
#
# PROMPT='$GIT_PROMPT_INFO# '
#
# git_prompt_format_simple ()
# { # {
# git_prompt__branch # git_prompt__branch
# local branch_=$GIT_PROMPT_BRANCH # local branch_=$GIT_PROMPT_BRANCH
@ -48,7 +64,7 @@
# fi # fi
# fi # fi
# #
# _GIT_PROMPT_INFO="$R($branch_$index_)$R" # GIT_PROMPT_INFO="$R($branch_$index_)$R"
# } # }
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# #
@ -465,10 +481,8 @@ git_prompt__dirty_state ()
} }
#------------------ Default Prompt Format ------------------ #------------------ Default Prompt Format ------------------
# You can override this by defining your own _git_prompt_info in your theme that
# sets $_GIT_PROMPT_INFO.
# You can override these colors if you like too. # You can override these colors if you like.
# Colors ('_C' for color): # Colors ('_C' for color):
if [[ "$DISABLE_COLOR" != "true" ]]; then if [[ "$DISABLE_COLOR" != "true" ]]; then
@ -488,12 +502,12 @@ if [[ "$DISABLE_COLOR" != "true" ]]; then
local R="%{$terminfo[sgr0]%}" local R="%{$terminfo[sgr0]%}"
fi fi
# sets _GIT_PROMPT_INFO # sets GIT_PROMPT_INFO
_git_prompt_info () git_prompt_info_default ()
{ {
local dir_="$(git_prompt__git_dir)" local dir_="$(git_prompt__git_dir)"
if [ -z "$dir_" ]; then if [ -z "$dir_" ]; then
_GIT_PROMPT_INFO='' GIT_PROMPT_INFO=''
return return
fi fi
@ -517,7 +531,7 @@ _git_prompt_info ()
if [ -z "$branch_$index_$work_$untracked_" ]; then if [ -z "$branch_$index_$work_$untracked_" ]; then
if [ -n "$dir_" ]; then if [ -n "$dir_" ]; then
_GIT_PROMPT_INFO="$R$_Cerror_(Error: bad ./$dir_ dir)$R" GIT_PROMPT_INFO="$R$_Cerror_(Error: bad ./$dir_ dir)$R"
return return
fi fi
fi fi
@ -563,7 +577,7 @@ _git_prompt_info ()
_prompt="($_prompt)" _prompt="($_prompt)"
fi fi
_GIT_PROMPT_INFO="$R$_prompt$R" GIT_PROMPT_INFO="$R$_prompt$R"
} }
#------------------ Fast Prompt ------------------ #------------------ Fast Prompt ------------------
@ -585,10 +599,10 @@ chpwd_functions+="_git_prompt_info"
PERIOD=15 PERIOD=15
periodic_functions+="_git_prompt_info" periodic_functions+="_git_prompt_info"
# Prime the pump; this will be executed before PROMPT is defined by the theme, So _git_prompt_info ()
# make sure the first prompt when the shell is opened has the git info set {
# properly. $GIT_PROMPT_INFO_FUNC
_git_prompt_info }
_git_prompt__precmd_update_git_vars() _git_prompt__precmd_update_git_vars()
{ {
@ -618,10 +632,3 @@ _git_prompt__preexec_update_git_vars ()
esac esac
} }
#--------------------------------------------------
git_prompt_info2()
{
echo $_GIT_PROMPT_INFO
}

@ -34,12 +34,16 @@ fi
#-------------------- PROMPT definition: ---------------------- #-------------------- PROMPT definition: ----------------------
# #
local user_="%(!.$_Cuser_root_.$_Cuser_)%n$R" local user_="%(!.$_Cuser_root_.$_Cuser_)%n$R"
local host_="%(!.$_Chost_root_.$_Chost_)%m$R" local host_="%(!.$_Chost_root_.$_Chost_)%m$R"
local path_="%(!.$_Cpath_root_.$_Cpath_)%~$R" local path_="%(!.$_Cpath_root_.$_Cpath_)%~$R"
local jobs_="%(1j.$_Cjobs_%j$R.)" local jobs_="%(1j.$_Cjobs_%j$R.)"
PROMPT='$user_$host_$path_ $(git_prompt_info2)$jobs_# ' # git_prompt_info_default() will set $GIT_PROMPT_INFO
GIT_PROMPT_INFO_FUNC=git_prompt_info_default
PROMPT='$user_$host_$path_ $GIT_PROMPT_INFO$jobs_# '
local date_format_='%D{%a %b %d}, %*' local date_format_='%D{%a %b %d}, %*'
local date_="${_Cdate_}[$date_format_]$R" local date_="${_Cdate_}[$date_format_]$R"

Loading…
Cancel
Save