Skip to content

Instantly share code, notes, and snippets.

@hassek
Created March 5, 2013 20:24
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 hassek/5093950 to your computer and use it in GitHub Desktop.
Save hassek/5093950 to your computer and use it in GitHub Desktop.
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/Cellar/ruby/1.9.3-p194/bin:/usr/local/share/npm/bin:$PATH
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/Cellar/python26/2.6.7/bin:/usr/local/Cellar/python/2.7.3/bin:/usr/local/share/python:$PATH
export PYTHONPATH=${PYTHONPATH}:$HOME/gsutil/boto:$HOME/gsutil:/usr/local/Cellar/xapian/1.2.7/bin:/usr/local/Cellar/readline/6.2.2/:
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
# virtualenv installation
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
#virtualenv aliases
# http://blog.doughellmann.com/2010/01/virtualenvwrapper-tips-and-tricks.html
export VSITEPACKAGE='`virtualenvwrapper_get_site_packages_dir`'
alias v='workon'
alias v.deactivate='deactivate'
alias v.mk='mkvirtualenv -p /usr/local/bin/python2.7'
alias v.mk26='mkvirtualenv -p /usr/local/bin/python2.6'
alias v.rm='rmvirtualenv'
alias v.switch='workon'
alias v.add2virtualenv='add2virtualenv'
alias v.cdsitepackages='cdsitepackages'
alias v.cd='cdvirtualenv'
alias v.lssitepackages='lssitepackages'
alias gdmvim='mvim -p $(git diff --name-only)'
alias rvim='mvim --remote-tab-silent'
#Git branch name
#export PS1="\[\033[38m\]\u@\h\[\033[01;34m\] \w \[\033[31m\]\`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`\[\033[37m\]$\[\033[00m\] "
### PS1 customization ####
NONE="\[\033[0m\]" # unsets color to term fg color
# regular colors
K="\[\033[0;30m\]" # black
R="\[\033[0;31m\]" # red
G="\[\033[0;32m\]" # green
Y="\[\033[0;33m\]" # yellow
B="\[\033[0;34m\]" # blue
M="\[\033[0;35m\]" # magenta
C="\[\033[0;36m\]" # cyan
W="\[\033[0;37m\]" # white
# emphasized (bolded) colors
EMK="\[\033[1;30m\]"
EMR="\[\033[1;31m\]"
EMG="\[\033[1;32m\]"
EMY="\[\033[1;33m\]"
EMB="\[\033[1;34m\]"
EMM="\[\033[1;35m\]"
EMC="\[\033[1;36m\]"
EMW="\[\033[1;37m\]"
# background colors
BGK="\[\033[40m\]"
BGR="\[\033[41m\]"
BGG="\[\033[42m\]"
BGY="\[\033[43m\]"
BGB="\[\033[44m\]"
BGM="\[\033[45m\]"
BGC="\[\033[46m\]"
BGW="\[\033[47m\]"
# displays only the last 25 characters of pwd
set_new_pwd() {
# How many characters of the $PWD should be kept
local pwdmaxlen=25
# Indicate that there has been dir truncation
local trunc_symbol=".."
local dir=${PWD##*/}
pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
NEW_PWD=${PWD/#$HOME/\~}
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))
if [ ${pwdoffset} -gt "0" ]
then
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}
NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}
fi
}
# the name of the git branch in the current directory
set_git_branch() {
unset GIT_BRANCH
local branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1 /'`;
if test $branch
then
GIT_BRANCH="${EMG}git:${NONE}$branch"
fi
}
# revision of the svn repo in the current directory
set_svn_rev() {
unset SVN_REV
local rev=`svn info 2> /dev/null | grep "Revision" | sed 's/Revision: \(.*\)/r\1 /'`;
if test $rev
then
SVN_REV="${EMG}svn:${NONE}$rev"
fi
}
# the name of the activated virtual env
set_virtual_env_base() {
unset VIRTUAL_ENV_BASE
local venv=`basename "$VIRTUAL_ENV"`
if test $venv
then
VIRTUAL_ENV_BASE="${EMG}env:${NONE}$venv "
fi
}
update_prompt() {
set_new_pwd
set_git_branch
set_svn_rev
set_virtual_env_base
PS1="${EMB}[${NONE}${NEW_PWD}${EMB}] ${GIT_BRANCH}${SVN_REV}${VIRTUAL_ENV_BASE}${B}\$ ${NONE}"
}
PROMPT_COMMAND=update_prompt
##
# Your previous /Users/Tommy/.bash_profile file was backed up as /Users/Tommy/.bash_profile.macports-saved_2012-01-19_at_00:57:24
##
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
fortune -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment