Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# ~/.bash_profile
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
GIT_PS1_SHOWDIRTYSTATE=true
source ~/.git-prompt.sh
export PS1='[\u@mbp \w$(__git_ps1)]\$ '
export PATH=~/bin:/usr/local/bin:/bin:$PATH
export PATH="/usr/local/share/npm/bin:$PATH"
export PATH=~/.rbenv/shims:$PATH
export EDITOR='subl -w'
export PROMPT_COMMAND='echo -ne "\033]2;${USER}@${HOSTNAME%%.*}: ${PWD/#$HOME/~}\007"'
get_git_branch() {
echo `git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
}
get_master_ancestor() {
echo `git merge-base HEAD master 2> /dev/null`
}
get_integration_ancestor() {
echo `git merge-base HEAD integration 2> /dev/null`
}
## Dev Specific
alias heorku='heroku'
alias deploy='git push heroku `get_git_branch`:master'
alias deployf='git push heroku `get_git_branch`:master -f'
alias fs='foreman start -f Procfile.dev'
alias demo:reset='foreman run rake db:reset demo:seed db:test:prepare'
## Git
gc() {
git add .
git add -u
if [ $? -eq 0 ]
then
eval "git commit -m '$*'"
else
(exit $?)
fi
}
gcap() {
gc $*
if [ $? -eq 0 ]
then
pullr && push
else
(exit $?)
fi
}
alias pull='git pull origin `get_git_branch`'
alias pullr='git pull --rebase origin `get_git_branch`'
alias push='git push origin `get_git_branch`'
alias pushf='if [ `get_git_branch` = "master" ]; then echo error: force pushing to master cannot be done automatically; else git push origin `get_git_branch` -f; fi'
alias gs='git status'
alias gch='git checkout'
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
alias gcam="git commit -a --amend"
alias gcamfp="gcam && pushf"
alias head="git rev-parse HEAD"
alias squash="git fetch origin master:master && git rebase \`get_master_ancestor\` -i"
alias rebase="git fetch origin master:master && git rebase master -i"
alias isquash="git fetch origin integration:integration && git rebase \`get_integration_ancestor\` -i"
alias irebase="git fetch origin integration:integration && git rebase integration -i"
alias spp='git stash && git pull --rebase origin `get_git_branch` && git stash pop'
# @todo make smarter to pull first branch that isn't this branch
# instead of being hard-coded to master
alias bduc='_BRANCH=`get_git_branch` && git stash && git checkout master && git branch -D $_BRANCH && git remote update origin && git checkout $_BRANCH'
## Github
# gh - opens github.com to current repo/branch page
alias gh="open \`git remote get-url --push origin | sed 's/git@github.com:/https:\/\/github.com\//g'\`/tree/\`get_git_branch\`"
## PG
alias pgrestore="pg_restore --verbose --clean --no-acl --no-owner -h localhost -U rails -d timebomb-web_dev "
## java
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
## Cassandra
export PATH=/usr/local/cassandra/tools/bin:$PATH
export PATH=/usr/local/cassandra/bin:$PATH
get_cassandra_pid() {
echo `ps -awx | grep cassandra | grep -v grep | awk '{print $1}'`
}
killcass(){
PID=$(get_cassandra_pid)
sudo kill `get_cassandra_pid`
kill -0 $PID 2> /dev/null
while [ $? -eq 0 ]
do
sleep 1
kill -0 $PID 2> /dev/null
done
echo '[✓] Cassandra stopped'
}
startcass() {
echo 'Starting Cassandra...'
CASSANDRA_OUTPUT=`cassandra | grep 'ERROR\|state jump'`
if [[ $CASSANDRA_OUTPUT == *"state jump to NORMAL"* ]]
then
echo '[✓] Cassandra Running'
else
echo -e "\033[0;31m"$CASSANDRA_OUTPUT"\033[0m"
echo '[✘] Cassandra Failed to Start'
fi
}
alias kickcass="killcass && startcass"
cassrestore() {
~/cassandra_restore.sh $1
}
switchcass() {
killcass
if [ -d /usr/local/cassandra ]; then rm /usr/local/cassandra; fi
ln -s $1 /usr/local/cassandra
source ~/.bash_profile
echo '[✓] Switched to Cassandra at' `ls -la /usr/local/cassandra | sed 's/.*->\(.*\)/\1/'`
startcass
}
sstableshow() {
if [[ "$3" == "-v" ]]
then
echo -e "Verbose digest of most recent matching sstable:\n\n"
sstabledump `sstableutil $1 $2 | grep Data.db`
else
echo -e "Compact digest of most recent matching sstable:\n\n"
sstabledump `sstableutil $1 $2 | grep Data.db` -d
fi
}
## Spark
export PATH=/usr/local/spark/bin:$PATH
alias startspark="/usr/local/spark/sbin/start-all.sh"
alias stopspark="/usr/local/spark/sbin/stop-all.sh"
## AWS
aws_api_deploy() {
echo '"api:"' &&
aws deploy create-deployment --application-name api --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name $1 --github-location repository=timebomb-app/timebomb-api,commitId=$2 &&
echo '"worker:"' &&
aws deploy create-deployment --application-name worker --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name $1 --github-location repository=timebomb-app/timebomb-api,commitId=$2
}
aws_web_deploy() {
echo '"www:"' &&
aws deploy create-deployment --application-name web --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name $1 --github-location repository=timebomb-app/timebomb-web,commitId=$2
}
aws_deploy_status() {
aws deploy get-deployment --deployment-id $1 --query "deploymentInfo.[status, creator]" --output text
}
aws_web_deployment_info() {
aws deploy get-deployment-group --deployment-group-name $1 --application-name timebomb-www
}
aws_api_deployment_info() {
aws deploy get-deployment-group --deployment-group-name $1-timebomb-worker-api --application-name timebomb-worker && \
aws deploy get-deployment-group --deployment-group-name $1-timebomb-web-api --application-name timebomb-web
}
alias deployapi='aws_api_deploy'
alias deployweb='aws_web_deploy'
alias deploystatus='aws_deploy_status'
alias webinfo='aws_web_deployment_info'
alias apiinfo='aws_api_deployment_info'
alias envshas='ruby ~/source/hacking/aws_deployment_info.rb'
alias whichsha='git log --format=%B -n 1'
## Timebomb Specific
export DEVELOPMENT_MACHINE='true'
export NVM_DIR="$HOME/.nvm"
. "/usr/local/opt/nvm/nvm.sh"
export PATH="/usr/local/opt/qt@5.5/bin:$PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.