Skip to content

Instantly share code, notes, and snippets.

@michaelminter
Forked from yujiberra/gist:1144329
Created October 1, 2012 17:47
Show Gist options
  • Select an option

  • Save michaelminter/3813288 to your computer and use it in GitHub Desktop.

Select an option

Save michaelminter/3813288 to your computer and use it in GitHub Desktop.

Revisions

  1. michaelminter renamed this gist Oct 1, 2012. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.txt → branch-color.sh
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ bldpur='\033[1;35m' # Purple
    bldcyn='\033[1;36m' # Cyan

    # Set color for the directory listing in the prompt
    dir_listing_color=$bldgrn
    dir_listing_color=$txtpur

    # Set colors for different repository states
    unmerged_color=$bldpur
    @@ -54,9 +54,9 @@ function git_branch {
    untracked="*"
    fi
    if [ "`expr "$git_branch" : '.*'`" -gt "0" ]; then
    echo \($git_branch$untracked\)
    echo " "$git_branch$untracked
    fi
    }

    PS1='\[`echo -e $dir_listing_color`\]\w \[`git_color`\]`git_branch` \[\e[0m\]$ '
    PS1='\[`echo -e $dir_listing_color`\]\w\[`git_color`\]`git_branch`\[\e[0m\]$ '
    PS2="> "
  2. @yujiberra yujiberra revised this gist Aug 16, 2011. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -29,8 +29,8 @@ bldcyn='\033[1;36m' # Cyan
    dir_listing_color=$bldgrn

    # Set colors for different repository states
    unmerged_color=$bldred
    unstaged_color=$bldpur
    unmerged_color=$bldpur
    unstaged_color=$bldred
    staged_color=$bldcyn
    clean_color=$bldblu

    @@ -53,8 +53,10 @@ function git_branch {
    if [ -n "`git status 2> /dev/null | grep "# Untracked files:"`" ]; then
    untracked="*"
    fi
    echo $git_branch$untracked
    if [ "`expr "$git_branch" : '.*'`" -gt "0" ]; then
    echo \($git_branch$untracked\)
    fi
    }

    PS1='\[`echo -e $dir_listing_color`\]\w \[`git_color`\](`git_branch`) \[\e[0m\]$ '
    PS1='\[`echo -e $dir_listing_color`\]\w \[`git_color`\]`git_branch` \[\e[0m\]$ '
    PS2="> "
  3. @yujiberra yujiberra revised this gist Aug 16, 2011. 1 changed file with 22 additions and 1 deletion.
    23 changes: 22 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,22 @@
    # Git status bash prompt
    #
    # In addition to printing the current working directory, this prompt will
    # show a number of things if you are in a git repository:
    # - The current branch you are in
    # - Whether there are untracked files in the repository (there will be an
    # asterisk after the branch nome if there are)
    # - Whether there are any unmerged/unstaged/staged changes or if the directory
    # is clean. See below for the colors that will be used, and change them if
    # you'd like.

    # Storing these color codes for later use
    txtblk='\033[0;30m' # Black - Regular
    txtred='\033[0;31m' # Red
    txtgrn='\033[0;32m' # Green
    txtylw='\033[0;33m' # Yellow
    txtblu='\033[0;34m' # Blue
    txtpur='\033[0;35m' # Purple
    txtcyn='\033[0;36m' # Cyan
    bldblk='\033[1;30m' # Black - Bold
    bldred='\033[1;31m' # Red
    bldgrn='\033[1;32m' # Green
    @@ -6,8 +25,10 @@ bldblu='\033[1;34m' # Blue
    bldpur='\033[1;35m' # Purple
    bldcyn='\033[1;36m' # Cyan

    # Set color for the directory listing in the prompt
    dir_listing_color=$bldgrn

    # Set colors for different repository states
    unmerged_color=$bldred
    unstaged_color=$bldpur
    staged_color=$bldcyn
    @@ -36,4 +57,4 @@ function git_branch {
    }

    PS1='\[`echo -e $dir_listing_color`\]\w \[`git_color`\](`git_branch`) \[\e[0m\]$ '
    PS2="> "
    PS2="> "
  4. @yujiberra yujiberra revised this gist Aug 16, 2011. 1 changed file with 36 additions and 5 deletions.
    41 changes: 36 additions & 5 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,39 @@
    function parse_git_dirty {
    [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo -e '\033[1;33m'
    bldblk='\033[1;30m' # Black - Bold
    bldred='\033[1;31m' # Red
    bldgrn='\033[1;32m' # Green
    bldylw='\033[1;33m' # Yellow
    bldblu='\033[1;34m' # Blue
    bldpur='\033[1;35m' # Purple
    bldcyn='\033[1;36m' # Cyan

    dir_listing_color=$bldgrn

    unmerged_color=$bldred
    unstaged_color=$bldpur
    staged_color=$bldcyn
    clean_color=$bldblu

    function git_color {
    git_status=`git status 2> /dev/null`

    if [ -n "`echo $git_status | grep "# Unmerged paths:"`" ]; then
    echo -e $unmerged_color
    elif [ -n "`echo $git_status | grep "# Changes not staged for commit:"`" ]; then
    echo -e $unstaged_color
    elif [ -n "`echo $git_status | grep "# Changes to be committed:"`" ]; then
    echo -e $staged_color
    else
    echo -e $clean_color
    fi
    }
    function parse_git_branch {
    git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'

    function git_branch {
    git_branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
    if [ -n "`git status 2> /dev/null | grep "# Untracked files:"`" ]; then
    untracked="*"
    fi
    echo $git_branch$untracked
    }

    PS1='\[\e[1;35m\]\w \[\e[1;32m\]$(parse_git_dirty)$(parse_git_branch)\[\e[0m\]$ '
    PS1='\[`echo -e $dir_listing_color`\]\w \[`git_color`\](`git_branch`) \[\e[0m\]$ '
    PS2="> "
  5. @yujiberra yujiberra created this gist Aug 13, 2011.
    8 changes: 8 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    function parse_git_dirty {
    [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo -e '\033[1;33m'
    }
    function parse_git_branch {
    git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
    }

    PS1='\[\e[1;35m\]\w \[\e[1;32m\]$(parse_git_dirty)$(parse_git_branch)\[\e[0m\]$ '