Skip to content

Instantly share code, notes, and snippets.

@jacqui
Forked from tysone/snippet.sh
Created December 15, 2011 19:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacqui/1482565 to your computer and use it in GitHub Desktop.
Save jacqui/1482565 to your computer and use it in GitHub Desktop.
Display current rvm gemset and git branch in your prompt (bash).
# Adapted from: http://ariejan.net/2010/04/25/ruby-version-and-gemset-in-your-bash-prompt-yes-sir
function rvm_version {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && echo "@$gemset"
}
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
# defines '__git_ps1' current git branch function
source ~/.git-completion.bash
export PS1="\$(rvm_version) \$(__git_ps1 '(%s)') \$ "
@jacqui
Copy link
Author

jacqui commented Dec 15, 2011

looks like:

@olympics_2012 (feature/parse_some_xml) $

@tysone
Copy link

tysone commented Dec 15, 2011

And, with colors!

function rvm_version {
  local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
  [ "$gemset" != "" ] && echo "@$gemset"
}

export PS1='\[\033[1;34m\]$(rvm_version)\[\033[0m\] \W$(__git_ps1 "\[\033[1;32m\](%s)\[\033[0m\]") \$ '

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment