Mac OSX git request

I played with the .profile file in my home directory to show the git branch at the prompt, and also show rvm gemset and python virtual env Im currently ... basically everything is working fine, the problem I am facing is that in order to show a branch of a different color depending on the state of the branch, I have to do source ~ / .profile every time, also I have to do the same to show python virtualenv in CYAN.

Theres should be a way or something that Im missing, so I don’t have to run source ~ / .profile every time I go to another folder so that the color of the branch is based on status.

Heres my.profile

https://gist.github.com/3628788

Thanks for your help in this!

+5
source share
1 answer

Use the PROMPT_COMMAND variable to define the function that sets yours PS1after each command. Put this at the bottom of the .profile file instead of the destination PS1:

prompt_cmd () {
    PS1="${PYTHON_VIRTUALENV}$PURPLE\$(set_rvm_prompt)$NO_COLOUR\u@\h:[\W]${B_STATE}\$(parse_git_branch)$NO_COLOUR\$ "
}

PROMPT_COMMAND=prompt_cmd

Now, before displaying the prompt, it bashwill execute the function prompt_cmd, updating PS1for the latest information in accordance with PYTHON_VIRTUALENV, set_rvm_prompt()and parse_git_branch().

+6
source

All Articles