Skip to content

Instantly share code, notes, and snippets.

@FrancoB411
Last active December 16, 2015 06:09
Show Gist options
  • Select an option

  • Save FrancoB411/5389132 to your computer and use it in GitHub Desktop.

Select an option

Save FrancoB411/5389132 to your computer and use it in GitHub Desktop.
my .bashrc with custom prompt
### Add RVM to PATH for scripting
PATH=$PATH:$HOME/.rvm/bin
### Add bin to my PATH
PATH=$HOME/bin:$PATH
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
### Adds RVM as a function
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
### Adds Postgres to Path
export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
### Adds color to ri
alias ri='ri -f ansi -T'
### Add Git Status to bash prompt
function prompt_command {
exitstatus="$?"
BOLD="\[\e[1m\]"
RED="\[\e[0;31m\]"
REDBG="\[\e[41m\]"
BLACKBG="\[\e[40m\]"
GREEN="\[\e[32;1m\]"
BLUE="\[\e[34;1m\]"
PURPLE="\[\e[35;1m\]"
CYAN="\[\e[36;1m\]"
OFF="\[\033[m\]"
DARK="\[\033[1;30m\]"
time=`date +"%H:%M"`
branch=`git symbolic-ref HEAD 2> /dev/null | cut -f3 -d/`
if [ ! -z ${branch} ]; then
if [ ${branch} == "master" ]; then
branch=`echo " ${REDBG} ${branch} ${BLACKBG}"`
else
branch=`echo " ${CYAN}${branch}"`
fi
fi
changes=`git status -s 2> /dev/null | \
wc -l | sed -e 's/ *//'`
if [ ${changes} -eq 0 ]; then
dirty=""
else
dirty="${RED}*${OFF}"
fi
### Add Heart Prompt
prompt="${GREEN}♥ ${DARK}${time} \
\w${OFF}${BOLD}${branch}${OFF}${dirty}"
if [ ${exitstatus} -eq 0 ]; then
PS1="${prompt} ${GREEN}\\$ ${OFF}"
else
PS1="${prompt} ${RED}\\$ ${OFF}"
fi
PS2="${BOLD}>${OFF} "
}
PROMPT_COMMAND=prompt_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment