Last active
January 16, 2019 02:27
-
-
Save Floppy/4606714 to your computer and use it in GitHub Desktop.
My ~/.bash_profile, with handy command-prompt display of ruby version, gemset, and git branch.
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
ESC="\033" # This is the escape sequence | |
NO_COLOR="$ESC[0m" | |
IRED="$ESC[1;31m" # ANSI color code for intense/bold red | |
IGRN="$ESC[1;32m" # ANSI color code for intense/bold green | |
# From http://railstips.org/blog/archives/2009/02/02/bedazzle-your-bash-prompt-with-git-info/ | |
# I had to change 'git-symbolic-ref' to 'git symbolic-ref' | |
function parse_git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo " ["${ref#refs/heads/}"]" # I wanted my branch wrapped in [], use () or <> or whatever | |
} | |
# from http://ariejan.net/2010/04/25/ruby-version-and-gemset-in-your-bash-prompt-yes-sir | |
function rvm_version { | |
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') | |
[ "$gemset" != "" ] && gemset="@$gemset" | |
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') | |
[ "$version" != "" ] && version="$version" | |
local full="$version$gemset" | |
[ "$full" != "" ] && echo "${full}:" # the colon at the end is a delimiter, you could use a space instead | |
} | |
#PS1="\h:\W \u\$" # For reference, here's the default OS X prompt | |
#export PS1="\$(rvm_version)\W \$(parse_git_branch)\$ " # Without the colors | |
# I had to put the \[ and \] down here, as opposed to $IRED, to avoid wrapping funkiness. | |
export PS1="\[$IRED\]\$(rvm_version)\[$NO_COLOR\]\W\[$IGRN\]\$(parse_git_branch)\[$NO_COLOR\] \$ " | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* | |
alias b='bundle exec' | |
alias brake='bundle exec rake' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment