Skip to content

Commit

Permalink
Add state and step
Browse files Browse the repository at this point in the history
fixes #360
  • Loading branch information
magicmonty committed Dec 21, 2017
1 parent f183825 commit d8d99a1
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 7 deletions.
12 changes: 6 additions & 6 deletions gitprompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,12 @@ function updatePrompt() {
__chk_gitvar_status 'REMOTE' '-n'
if [[ $GIT_CLEAN -eq 0 ]] || [[ $GIT_PROMPT_CLEAN != "" ]]; then
__add_status "$GIT_PROMPT_SEPARATOR"
__chk_gitvar_status 'STAGED' '-ne 0'
__chk_gitvar_status 'CONFLICTS' '-ne 0'
__chk_gitvar_status 'CHANGED' '-ne 0'
__chk_gitvar_status 'UNTRACKED' '-ne 0'
__chk_gitvar_status 'STASHED' '-ne 0'
__chk_gitvar_status 'CLEAN' '-eq 1' -
__chk_gitvar_status 'STAGED' '!= "0" -a $GIT_STAGED != "^"'
__chk_gitvar_status 'CONFLICTS' '!= "0"'
__chk_gitvar_status 'CHANGED' '!= "0"'
__chk_gitvar_status 'UNTRACKED' '!= "0"'
__chk_gitvar_status 'STASHED' '!= "0"'
__chk_gitvar_status 'CLEAN' '= "1"' -
fi
__add_status "$ResetColor$GIT_PROMPT_SUFFIX"

Expand Down
49 changes: 48 additions & 1 deletion gitstatus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,53 @@ gitstatus=$( LC_ALL=C git status ${_ignore_submodules} --untracked-files=${__GIT
# if the status is fatal, exit now
[[ "$?" -ne 0 ]] && exit 0

git_dir="$(git rev-parse --git-dir 2>/dev/null)"
[[ -z "$git_dir" ]] && exit 0

__git_prompt_read ()
{
local f="$1"
shift
test -r "$f" && read "$@" <"$f"
}

state=""
step=""
total=""
if [ -d "${git_dir}/rebase-merge" ]; then
__git_prompt_read "${git_dir}/rebase-merge/msgnum" step
__git_prompt_read "${git_dir}/rebase-merge/end" total
if [ -f "${git_dir}/rebase-merge/interactive" ]; then
state="|REBASE-i"
else
state="|REBASE-m"
fi
else
if [ -d "${git_dir}/rebase-apply" ]; then
__git_prompt_read "${git_dir}/rebase-apply/next" step
__git_prompt_read "${git_dir}/rebase-apply/last" total
if [ -f "${git_dir}/rebase-apply/rebasing" ]; then
state="|REBASE"
elif [ -f "${git_dir}/rebase-apply/applying" ]; then
state="|AM"
else
state="|AM/REBASE"
fi
elif [ -f "${git_dir}/MERGE_HEAD" ]; then
state="|MERGING"
elif [ -f "${git_dir}/CHERRY_PICK_HEAD" ]; then
state="|CHERRY-PICKING"
elif [ -f "${git_dir}/REVERT_HEAD" ]; then
state="|REVERTING"
elif [ -f "${git_dir}/BISECT_LOG" ]; then
state="|BISECTING"
fi
fi

if [ -n "$step" ] && [ -n "$total" ]; then
state="${state} ${step}/${total}"
fi

num_staged=0
num_changed=0
num_conflicts=0
Expand Down Expand Up @@ -118,7 +165,7 @@ if [[ -z "$upstream" ]] ; then
fi

printf "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n" \
"$branch" \
"${branch}${state}" \
"$remote" \
"$upstream" \
$num_staged \
Expand Down

0 comments on commit d8d99a1

Please sign in to comment.