Created
February 15, 2010 12:46
-
-
Save sergio-fry/304615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
def git_branch | |
(%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* ([a-z0-9_]+)[[:space:]]+$/i, '\1') | |
end | |
def set_color color | |
"\033[#{color}m" | |
end | |
def print_result result | |
print "#{set_color('37')}(#{result}#{set_color('37')}#{set_color('00')})" | |
end | |
if git_branch == 'master' | |
print_result "#{set_color('41')}#{set_color('32')}#{git_branch}" | |
elsif !git_branch.empty? | |
print_result "#{set_color('32')}#{git_branch}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment