Created
August 11, 2011 04:58
-
-
Save rupert-madden-abbott/1138934 to your computer and use it in GitHub Desktop.
Ubuntu first time setup: .bashrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add the following to ~/.bashrc | |
function parse_git_dirty() { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function ps1_git() { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/*\( .*\)/\1$(parse_git_dirty)/" | |
} | |
function ps1_rvm() { | |
[[ $(~/.rvm/bin/rvm-prompt g) != "@${PWD##*/}" ]] && echo "*" | |
} | |
# Replace the PS1 value with: | |
PS1="\[\033[1;32m\]Foo/\j \[\033[1;33m\]\W\$(ps1_rvm)\[\033[1;34m\]\$(ps1_git) \[\033[00m\]\$ " | |
# \[\033[1;32m\] - Switch to green text | |
# Foo - I prefer to give my comps a unique name in the prompt rather than muck around with changing the hostname | |
# \j - Display how many background jobs are running. | |
# \[\033[1;33m\] - Yellow text | |
# \W - Display the current directory - I prefer this to the path as otherwise my prompt gets too long | |
# \$(ps1_rvm) - Display an asterisk if the current directory and the current rvm gemset are not the same. I give my gemsets the same name as my projects. | |
# \[\033[1;34m\] - Blue text | |
# \$(ps1_git) - Display the git branch when in a git repo with an asterisk if there are uncommitted files | |
# \[\033[00m\] - Back to white text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment