Skip to content

Instantly share code, notes, and snippets.

@todb
Created April 30, 2012 02:50
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save todb/2555109 to your computer and use it in GitHub Desktop.
Save todb/2555109 to your computer and use it in GitHub Desktop.
Stick this in your bashrc and don't wonder what branch/ruby/gemset you're using
# Git and RVM prompting
function git-current-branch {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
export PS1="[\$(~/.rvm/bin/rvm-prompt v p g)] \$(git-current-branch)$PS1"
@todb
Copy link
Author

todb commented Apr 30, 2012

After several abortive attempts because I'm bash-challenged, this seems to work as you'd expect.

@todb
Copy link
Author

todb commented Apr 30, 2012

Makes my prompt look like:

[1.9.3-p125] (master) mazikeen:./metasploit-framework$

@todb-r7
Copy link

todb-r7 commented Jan 29, 2013

Hrm, rvm-prompt may not work any more. Oh well, it's not like we're doing a lot of ruby version changing any more these days.

@mcfakepants
Copy link

As of today, it looks like rvm-prompt once again functions correctly.

@d3bluff
Copy link

d3bluff commented Jun 19, 2014

Very good but I don't like that it's showing up [ ] before promt while in interactive shell.
I commented that, and uncomment only when needed.
thank you for sharing :)

@wvu
Copy link

wvu commented Aug 29, 2014

You could use git branch 2> /dev/null | sed -n 's/^\* //p' and put the parens in your $PS1. :)

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