Merge 53d29f28aa into 2813930e04
commit
db2f62d2a9
|
|
@ -3,6 +3,8 @@
|
|||
THEME_PROMPT_HOST='\H'
|
||||
SCM_THEME_PROMPT_DIRTY=' ✗'
|
||||
SCM_THEME_PROMPT_CLEAN=' ✓'
|
||||
SCM_THEME_PROMPT_AHEAD=" ↑"
|
||||
SCM_THEME_PROMPT_BEHIND=" ↓"
|
||||
SCM_THEME_PROMPT_PREFIX=' |'
|
||||
SCM_THEME_PROMPT_SUFFIX='|'
|
||||
|
||||
|
|
@ -69,6 +71,30 @@ function scm_prompt_info {
|
|||
[[ $SCM == $SCM_SVN ]] && svn_prompt_info && return
|
||||
}
|
||||
|
||||
function current_branch() {
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||
echo ${ref#refs/heads/}
|
||||
}
|
||||
|
||||
function remote_head() {
|
||||
remote_head=$(git ls-remote origin -h refs/heads/$(current_branch) | cut -c 1-40) || return
|
||||
echo $remote_head
|
||||
}
|
||||
|
||||
# Checks if there are commits ahead from remote
|
||||
function git_prompt_ahead() {
|
||||
if [[ -n $(git log origin/$(current_branch)...HEAD --right-only 2> /dev/null | grep '^commit') ]]; then
|
||||
echo -e "$SCM_THEME_PROMPT_AHEAD"
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if there are commits available from remote
|
||||
function git_prompt_behind() {
|
||||
if [[ -n $(git rev-list $(remote_head) 2>&1 | grep "bad object") ]]; then
|
||||
echo -e "$SCM_THEME_PROMPT_BEHIND"
|
||||
fi
|
||||
}
|
||||
|
||||
function git_prompt_vars {
|
||||
if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then
|
||||
SCM_DIRTY=1
|
||||
|
|
@ -146,7 +172,7 @@ function virtualenv_prompt {
|
|||
# backwards-compatibility
|
||||
function git_prompt_info {
|
||||
git_prompt_vars
|
||||
echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_SUFFIX"
|
||||
echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$(git_prompt_behind)$(git_prompt_ahead)$SCM_SUFFIX"
|
||||
}
|
||||
|
||||
function svn_prompt_info {
|
||||
|
|
|
|||
Loading…
Reference in New Issue