Skip to content

Instantly share code, notes, and snippets.

@vanhalt
Created July 23, 2013 16:04

Revisions

  1. vanhalt created this gist Jul 23, 2013.
    6 changes: 6 additions & 0 deletions .bash_profile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    # Your stuffs

    PATH="$PATH:/Users/your_name/bin" # add the python script to your path
    PS1='\w [$(git_branch)] >> ' # the magic are the single quotes ;)

    # more of your stuffs
    13 changes: 13 additions & 0 deletions git_branch.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!usr/bin/python
    import subprocess
    import sys

    branches = subprocess.Popen(["git", "branch"], stdout = subprocess.PIPE, stderr = subprocess.STDOUT).communicate()[0]

    name = '-'

    for branch in branches.split("\n"):
    if branch.find('*') > -1:
    name = branch.split('*')[-1].strip()

    sys.stdout.write(name)