Skip to content

Instantly share code, notes, and snippets.

@rcmachado
Created December 29, 2011 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcmachado/1534014 to your computer and use it in GitHub Desktop.
Save rcmachado/1534014 to your computer and use it in GitHub Desktop.
bash_profile
# Activate RVM
function rvm_activate {
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
}
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\[\e[36;1m\]\w\[\e[0m\] $(__git_ps1 "[\[\e[0;32m\]%s\[\e[0m\]\[\e[0;33m\]$(parse_git_dirty)\[\e[0m\]]")\n\$ \[\e[0m\]'
# Amazon command line tools
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
export EC2_PRIVATE_KEY="$(/bin/ls $HOME/.ec2/pk-*.pem)"
export EC2_CERT="$(/bin/ls $HOME/.ec2/cert-*.pem)"
export AWS_ELASTICACHE_HOME="/usr/local/Cellar/aws-elasticache/1.5.0/jars"
export EC2_HOME="/usr/local/Cellar/ec2-api-tools/1.5.0.1/jars"
# Node
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/share/python:/usr/local/share/npm/bin:$PATH"
export NODE_PATH="/usr/local/lib/node:/usr/local/lib/node_modules:$NODE_PATH"
# VirtualenvWrapper
export WORKON_HOME="$HOME/Developer/virtualenvs"
source /usr/local/share/python/virtualenvwrapper.sh
# Homebrew bash completion
HOMEBREW_PREFIX=`brew --prefix`
if [ -f "$HOMEBREW_PREFIX/etc/bash_completion" ]; then
. "$HOMEBREW_PREFIX/etc/bash_completion"
fi
# pip bash completion
_pip_completion()
{
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
COMP_CWORD=$COMP_CWORD \
PIP_AUTO_COMPLETE=1 $1 ) )
}
complete -o default -F _pip_completion pip
# Django bash completion
_django_completion()
{
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
COMP_CWORD=$COMP_CWORD \
DJANGO_AUTO_COMPLETE=1 $1 ) )
}
complete -F _django_completion -o default django-admin.py manage.py django-admin
_python_django_completion()
{
if [[ ${COMP_CWORD} -ge 2 ]]; then
PYTHON_EXE=$( basename -- ${COMP_WORDS[0]} )
echo $PYTHON_EXE | egrep "python([2-9]\.[0-9])?" >/dev/null 2>&1
if [[ $? == 0 ]]; then
PYTHON_SCRIPT=$( basename -- ${COMP_WORDS[1]} )
echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
if [[ $? == 0 ]]; then
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
COMP_CWORD=$(( COMP_CWORD-1 )) \
DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) )
fi
fi
fi
}
# Support for multiple interpreters.
unset pythons
if command -v whereis &>/dev/null; then
python_interpreters=$(whereis python | cut -d " " -f 2-)
for python in $python_interpreters; do
pythons="${pythons} $(basename -- $python)"
done
pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ")
else
pythons=python
fi
complete -F _python_django_completion -o default $pythons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment