Adding colored status indicator to branches. #137

Open
wants to merge 3 commits into
from

Projects

None yet

3 participants

@manix84

Removed * to indicate change, replaced by the following colours:
Green: Working copy is clean.
Yellow: Changes have been added, and need to be committed.
Red/Magenta: Changed have been made, but not added.

Added the following 'Remote' indicators:
[↑]: Your branch is ahead of remote.
[↓]: Your branch is behind remote.
[↕]: Your branch and remote have diverged.

@manix84 manix84 Adding colored status indicator to branches.
Removed * to indicate change, replaced by the following colours:
    Green:       Working copy is clean.
    Yellow:      Changes have been added, and need to be committed.
    Red/Magenta: Changed have been made, but not added.

Added the following 'Remote' indicators:
    [↑]: Your branch is ahead of remote.
    [↓]: Your branch is behind remote.
    [↕]: Your branch and remote have diverged.
3e88f6a
@mathiasbynens mathiasbynens and 1 other commented on an outdated diff Sep 7, 2012
+ branch_pattern="^# On branch ([^${IFS}]*)"
+ if [[ ${git_status} =~ ${branch_pattern} ]]; then
+ branch_name=${BASH_REMATCH[1]}
+ fi
+
+ # Set the final branch string.
+ echo "${WHITE} on ${local_state}${branch_name}${remote_state}${RESET} "
+}
+function get_branch_name() {
+ if is_git_repository ; then
+ echo $(get_git_branch_name)
+ fi
+ echo ""
+}
+export PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$(get_branch_name)\n\$ \[$RESET\]"
@mathiasbynens
mathiasbynens Sep 7, 2012

The $ prompt gets a different color when the current working directory is a Git repository. Is that intentional?

@manix84
manix84 Sep 7, 2012

No, that's not intentional. I'll fix and resubmit. I hadn't noticed that, sorry. :)

Edit:
It should look something like this:
Coloured-Branch-Name Example
The purple was a change I just made, to bring it closer to your original look.

Edit 2:
Fixed. As you have shown, I was using a reset, and a white marker. Would you like me to resubmit, or submit a patch?

@oschrenk

I really like this. I need to build something like this for git-sh

@manix84 manix84 Setting folder colour to purple, to distinguish it from the branch.
Bringing example at the top of the page in line which the results.
09849e2
@manix84

I did not realise that when I committed changes to my remote branch they arrived here too. Very cool :D
The prompt looks like this now:
Coloured-Branch-Name Example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment