Created
November 12, 2009 20:40
-
-
Save bs/233258 to your computer and use it in GitHub Desktop.
This file contains 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
source $HOME/.bash/twitterrc | |
# rvm-install added line: | |
if [[ -s /Users/mbs/.rvm/scripts/rvm ]] ; then source /Users/mbs/.rvm/scripts/rvm ; fi | |
function c { | |
shopt -q nocasematch || resetcase=1 | |
shopt -s nocasematch | |
for i in *; do [ -d "$i" ] && [[ "$i" == *"$1"* ]] && cd "$i" && break; done | |
[ $resetcase ] && shopt -u nocasematch | |
} | |
shopt -s nocaseglob | |
shopt -s cdspell | |
shopt -s histappend | |
export HISTCONTROL=ignoreboth | |
export HISTSIZE=500 | |
export HISTFILESIZE=500 | |
export CLICOLOR=yes # Enable color ls output | |
export TERM=xterm-color # Flag terminal as color-capable | |
export LESS="-erX" # Disable screen clear after "less" and output colors correctly | |
CDPATH=".:~:/Applications" # NR: Search path for the cd command | |
Git && SVN | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ [\1]/' | |
} | |
parse_svn_branch() { | |
parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' | awk -F / '{print "["$1 "/" $2 "]"}' | |
} | |
parse_svn_url() { | |
svn info 2>/dev/null | grep -e '^URL*' | sed -e 's#^URL: *\(.*\)#\1#g ' | |
} | |
parse_svn_repository_root() { | |
svn info 2>/dev/null | grep -e '^Repository Root:*' | sed -e 's#^Repository Root: *\(.*\)#\1\/#g ' | |
} | |
# Show full path and git branch (if exists) in prompt | |
export PS1="\w\[\033[34m\]\$(parse_git_branch)\$(parse_svn_branch)\[\033[00m\] $\[\033[00m\] " | |
# git branch autocomplete | |
_complete_git() { | |
if [ -d .git ]; then | |
local all c s=$'\n' IFS=' '$'\t'$'\n' | |
branches=`git branch -a | cut -c 3-` | |
files=$( command ls ) | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
case "${prev}" in | |
origin) | |
COMPREPLY=( $(compgen -W "${branches}" -- ${cur}) ) ;; | |
*) | |
COMPREPLY=( $(compgen -W "${branches} ${files}" -- ${cur}) ) ;; | |
esac | |
fi | |
} | |
complete -o filenames -o dirnames -F _complete_git git checkout | |
function git-remote-branch() { | |
branch_name=$1 | |
git push origin origin:refs/heads/$branch_name | |
git fetch origin | |
git checkout -b $branch_name --track origin/$branch_name | |
git pull | |
} | |
function rf() { | |
environments=${*:-"test selenium development"} | |
if [ "$1" ]; then | |
environments {*:-"$*"} | |
fi | |
echo "Restarting memcache" | |
killall memcached | |
memcached -d | |
echo "Restarting kestrel" | |
rake kestrel:stop | |
rake kestrel:start | |
foreach_env " Dropping Database" "$environments" "dropdb" | |
foreach_env " Creating Database" "$environments" "createdb" | |
foreach_env "Migrating Database" "$environments" "migratedb" | |
foreach_env " Loading Fixtures" "$environments" "loadfixtures" | |
} | |
function foreach_env() { | |
msg=$1 | |
environments=$2 | |
command=$3 | |
echo -n "$msg: " | |
for env in $environments; do | |
echo -n "$env " | |
$command $env | |
done | |
echo | |
} | |
function dropdb() { | |
env=$1 | |
mysql --user=root -e "DROP DATABASE twttr_$env;" >/dev/null | |
} | |
function createdb() { | |
env=$1 | |
mysql --user=root -e "CREATE DATABASE twttr_$env;" >/dev/null | |
} | |
function migratedb() { | |
env=$1 | |
RAILS_ENV=$env rake db:migrate >/dev/null | |
} | |
function loadfixtures() { | |
env=$1 | |
RAILS_ENV=$env rake db:fixtures:load >/dev/null | |
} | |
## | |
# Your previous /Users/mbs/.bash_profile file was backed up as /Users/mbs/.bash_profile.macports-saved_2009-09-05_at_01:55:42 | |
## | |
# MacPorts Installer addition on 2009-09-05_at_01:55:42: adding an appropriate PATH variable for use with MacPorts. | |
export PATH=/opt/local/bin:/opt/local/sbin:$PATH | |
# Finished adapting your PATH environment variable for use with MacPorts. | |
SSHAGENT=/usr/bin/ssh-agent | |
SSHAGENTARGS="-s" | |
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then | |
eval `$SSHAGENT $SSHAGENTARGS` | |
trap "kill $SSH_AGENT_PID" 0 | |
fi | |
# rvm-install added line: | |
if [[ -s ~/.rvm/scripts/rvm ]] ; then source ~/.rvm/scripts/rvm ; fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment