Skip to content

Instantly share code, notes, and snippets.

@mwaskom
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwaskom/9244597 to your computer and use it in GitHub Desktop.
Save mwaskom/9244597 to your computer and use it in GitHub Desktop.
BASH prompt with current directory and git repository branch/state in a different color for each terminal window.
#! /usr/bin/env python
"""Randomly colored, useful BASH prompt.
Put this on your PATH `chmod u+x` it, and add
export PS1=`randps1.py`
to your .bash_profile file.
"""
from random import choice
colors = choice([1, 2]), 31 + choice(range(9))
print '\[\e[%d;%dm\]' % colors + '[\W]$(__git_ps1 "{%s}")\$\[\e[m\] '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment