Skip to content

Instantly share code, notes, and snippets.

@brenoperucchi
Created August 5, 2013 20:26
Show Gist options
  • Save brenoperucchi/6159298 to your computer and use it in GitHub Desktop.
Save brenoperucchi/6159298 to your computer and use it in GitHub Desktop.
Bash Prompt with GIT and RBENV Gemset and RubyVersion
# rbenv
export PATH="$HOME/.rbenv/bin:$PATH"
source ~/.git-prompt.sh
eval "$(rbenv init -)"
source ~/.rbenv/completions/rbenv.bash
# prompt with ruby version
# rbenv version | sed -e 's/ .*//'
__rbenv_ps1 ()
{
rbenv_ruby_version=`rbenv version | sed -e 's/ .*//'`
printf $rbenv_ruby_version
}
__rbenv_gemset ()
{
if [ -f Rakefile ] || [ -f Gemfile ] || [ -f .rbenv-gemsets ]; then
echo "@$(cat .rbenv-gemsets)";
fi
}
# prompt with git && rbenv
if [[ __git_ps1 ]] && [ -f `which rbenv` ]; then
export PS1='\[\033[01;32m\]\u@\h\[\033[01;33m\] \w$(__git_ps1) ruby=$(__rbenv_ps1)$(__rbenv_gemset) \n\[\033[01;34m\]\$\[\033[00m\] '
elif [[ __git_ps1 ]]; then
export PS1='\[\033[01;32m\]\u@\h\[\033[01;33m\] \w$(__git_ps1) \n\[\033[01;34m\]\$\[\033[00m\] '
elif [ `which rbenv` ]; then
export PS1='\[\033[01;32m\]\u@\h\[\033[01;33m\] \w ruby=$(__rbenv_ps1) \n\[\033[01;34m\]\$\[\033[00m\] '
else
export PS1='\[\033[01;32m\]\u@\h\[\033[01;33m\] \w \n\[\033[01;34m\]\$\[\033[00m\] '
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment