Skip to content

Commit

Permalink
Merge pull request rtomayko#13 from alex-morega/repo-state
Browse files Browse the repository at this point in the history
show if repository is during a rebase or merge
  • Loading branch information
rtomayko committed Aug 28, 2011
2 parents 978010f + b60c050 commit cbe5898
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion git-sh.bash
Expand Up @@ -177,7 +177,7 @@ _git_import_aliases () {

# PROMPT =======================================================================

PS1='`_git_headname`!`_git_workdir``_git_dirty`> '
PS1='`_git_headname`!`_git_repo_state``_git_workdir``_git_dirty`> '

ANSI_RESET="\001$(git config --get-color "" "reset")\002"

Expand Down Expand Up @@ -207,6 +207,19 @@ _git_workdir() {
_git_apply_color "${workdir/*\/}${subdir:+/$subdir}" "color.sh.workdir" "blue bold"
}

# detect if the repository is in a special state (rebase or merge)
_git_repo_state() {
local git_dir="$(git rev-parse --show-cdup).git"
if test -d "$git_dir/rebase-merge"; then
local state_marker="(rebase)"
elif test -f "$git_dir/MERGE_HEAD"; then
local state_marker="(merge)"
else
return 0
fi
_git_apply_color "$state_marker" "color.sh.repo-state" "red"
}

# determine whether color should be enabled. this checks git's color.ui
# option and then color.sh.
_git_color_enabled() {
Expand Down

0 comments on commit cbe5898

Please sign in to comment.