Skip to content

Instantly share code, notes, and snippets.

@dsibilly
Created July 3, 2012 00:30

Revisions

  1. dsibilly created this gist Jul 3, 2012.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    function parse_git_dirty {
    [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working direct
    ory clean)" ]] && echo "*"
    }

    function parse_git_branch {
    git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(par
    se_git_dirty)]/"
    }

    RED="\[\033[0;31m\]"
    YELLOW="\[\033[0;33m\]"
    GREEN="\[\033[0;32m\]"
    RESET="\[\033[0;0m\]"

    PS1="$RED\h:\W$YELLOW \$(parse_git_branch)$GREEN\$$RESET "