I am working with bash and still unfamiliar with the difference between .profile, .bashrc, .bash_profile.
My desired result is to have the ruby version and rvm gemset show up on my bash prompt.
I added PS1="\$(~/.rvm/bin/rvm-prompt) $PS1" to .bash_profile (via xcode) and it displays
ruby-1.9.3-p286 John-MacBook-Air:~ john$
What I trying to get is
ruby-1.9.3-p286@rails3 $
With “rails3” being the output of rvm gemset.
How do I get John-MacBook-Air:~ john removed from the prompt?
I tried adding the line in the .profile, and .bashrc with no luck but it seems to work in the .bash_profile. Any clarification between these files would be greatly appreciated. I am running rvm on a Mac.
SOLUTION
include the following to the .bash_profile
PS1='\W \$ '
PS1="\$(~/.rvm/bin/rvm-prompt) $PS1"
the prompt looks like
ruby-1.9.3-p286@rails3 ~ $
This line is the problem:
What you’re saying there is “add my rvm prompt to PS1” and then put the pre-existing
PS1at the end. The system’s defaultPS1is setting this:In that setting
\his the hostname (here ‘John-MacBook-Air’),\Wis the current working directory with your home directory abbreviated to~,\uis your user’s login name (here ‘john’) and\$will show a dollar sign if you are a regular user and an octothorpe (#) if you’re logged in as root. On OSX, that is set by default in/etc/bashrc. If you want to change the prompt, you need to customize the latter part of the prompt rather than just re-entering$PS1as is back into the new setting. Removing the hostname is common, but I would very strongly recommend against removing the current working directory. It’s very useful information when in a terminal session. Just my two cents.To see what you can put there, take a look for information about setting your prompt in Bash.