parrt / bash-git-prompt

My own variation on the bash git prompt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bash-git-prompt

What/Why?

My own variation on the bash git prompt. I took much of the ideas from magicmonty/bash-git-prompt. I wanted something simpler in functionality and implementation. Created some functions to organize. Here are some sample prompts:

parrt prompt

It shows the branch you are on and whether it is clean or not with a green or yellow branch name (clean means no staged or modified files).

It shows upward arrow if you are ahead and downward arrow if you are behind or both. Took me forever to figure out that you need to git fetch before computing "behind" works. :( Now correctly handles a fetch of remote for each repo every 30 minutes. Stores a small file in repo root: .fetch_time_cache.

Install

You can put file parrt-prompt.py anywhere but that incantation below assumes it's in the ~/.bash directory.

Add the following incantation to your .bash_profile or .bashrc, if you are using that file.

PROMPT_COMMAND='PS1="`python ~/.bash/parrt-prompt.py`"'

If you want to get fancy, the following variation will also set the title of the window (on OS X at least) to the current working directory.

PROMPT_COMMAND='echo -n -e "\033]0;`pwd`\007"; PS1="`python ~/.bash/parrt-prompt.py`"'

Misc

You might want to update the bash that sits on OS X by default:

$ bash --version
GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
Copyright (C) 2007 Free Software Foundation, Inc.
$ brew install bash
...
$ bash # launch new shell in this window or open new tab/window.
$ bash --version
GNU bash, version 4.3.18(1)-release (x86_64-apple-darwin13.3.0)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$

About

My own variation on the bash git prompt


Languages

Language:Python 100.0%