Created
November 20, 2010 12:41
-
-
Save samir/707793 to your computer and use it in GitHub Desktop.
Show current version of git, svn and rvm in prompt
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
# I made this gist to build my shell prompt based in various references on the web | |
# I will try to list the most of references, but sorry if I not put your here - | |
# http://henrik.nyh.se/2008/12/git-dirty-prompt (GIT) | |
# GIT | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ \(git: \1$(parse_git_dirty)\)/" | |
} | |
# SVN | |
function parse_svn_dirty { | |
[[ $(svn st 2> /dev/null) != "" ]] && echo "*" | |
} | |
function parse_svn_revision { | |
svn_revision="`svn info 2> /dev/null | grep "Revision:" --color=never | sed -e "s/Revision:/svn:/"`$(parse_svn_dirty)" | |
if [ "$svn_revision" != "" ] | |
then | |
echo " (${svn_revision})" | |
fi | |
echo | |
} | |
# RVM | |
function show_current_rvm { | |
rvm_version="`~/.rvm/bin/rvm-prompt i v g 2> /dev/null`" | |
if [ "$rvm_version" != "" ] | |
then | |
echo " (rvm: ${rvm_version})" | |
fi | |
} | |
function proml { | |
# Attribute codes: | |
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed | |
# Text color codes: | |
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white | |
# Background color codes: | |
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white | |
# \[\e[01;36m\] | |
PS1='\[\e]0;\w\a\]\n\[\e[01;33m\]\u\[\e[01;37m\]@\[\e[01;36m\]\h\[\e[01;37m\]\n\[\e[00;33m\]\w\[\e[01;31m\]$(parse_git_branch)\[\e[01;34m\]$(parse_svn_revision)\[\e[01;32m\]$(show_current_rvm)\n\[\033[37m\]$\[\033[00m\] ' | |
export PS1 | |
} | |
proml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment