Hacker News new | ask | show | jobs
by gknoy 3954 days ago
I like your `git watch` alias! That's very slick.

I like my git prompt to show me my branch name, colored with grey (no changes), red (unsaved changes), or green (staged changes), with the depth of the branch, e.g.:

    gknoy@host:~/dev/foo/[bar-feature:4]$ 

My prompt is based on: https://gist.github.com/tobiassjosten/828432

... but I've made slight modifications:

    # I sometimes have very long branch names.
    # I don't assume it's a hash:
    if [ ${#GIT_BRANCH} -gt 40 ]; then
        # GIT_BRANCH="(no branch)"
	GIT_BRANCH="${GIT_BRANCH:0:40}..."
    fi
and, at the end of `git_prompt`:

    branch_depth=`git rev-list HEAD --not --remotes|wc -l`
    echo "[$git_color$GIT_BRANCH$c_reset:${branch_depth}]"