Last active
December 26, 2015 12:39
-
-
Save xijo/7152610 to your computer and use it in GitHub Desktop.
.bash_profile
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 /usr/local/opt/chruby/share/chruby/chruby.sh | |
source /usr/local/opt/chruby/share/chruby/auto.sh | |
source ~/.git-completion.bash | |
# source ~/.rake_cap_bash_autocomplete.sh | |
export EDITOR='subl -w' | |
export SKIP_CLEANUP_DIRECTORIES='1' | |
export ANSIBLE_REMOTE_USER='johannes.opper' | |
alias sc='script/console' | |
alias lsc='RAILS_LOG=1 script/console' | |
alias android_js_debug='run_android_forwarding' | |
alias cdb='cd ~/scm/betterplace' | |
alias cde='cd ~/scm/epo' | |
alias cda='cd ~/scm/ansible-repo' | |
alias ci='bundle exec rake feature:ci:run:commit' | |
alias cir='PARALLEL_TEST_PROCESSORS=4 bundle exec rake ci:run' | |
alias cil='PARALLEL_TEST_PROCESSORS=4 bundle exec rake ci:run:local' | |
alias cif='PARALLEL_TEST_PROCESSORS=4 bundle exec rake parallel:features' | |
alias cis='PARALLEL_TEST_PROCESSORS=4 bundle exec rake parallel:spec' | |
alias slu='spring_update_locales' | |
alias scm='cd ~/scm/`ls ~/scm | pick`' | |
alias prepare='PARALLEL_TEST_PROCESSORS=4 bundle exec rake db:migrate parallel:{drop,create,migrate}' | |
alias gh_publish='git subtree push --prefix dist origin gh-pages' | |
alias tsung_stats='/usr/local/Cellar/tsung/1.5.1/lib/tsung/bin/tsung_stats.pl' | |
alias bx='bundle exec' | |
alias anpl='ansible-playbook' | |
alias anv='ansible-vault' | |
alias branches='git for-each-ref --sort=-committerdate --format="%(authorname) %(refname:short)" --count=300 $(git branch -r --no-merged origin/master | sed -e "s#^ *#refs/remotes/#")' | |
alias branches_joe='branches | grep Johannes' | |
# alias zrspec='[ -e .zeus.sock ] && bx zeus rspec || bx rspec' | |
alias sshconf='subl ~/.ssh/' | |
alias sshbuild='echo -n > ~/.ssh/config && cat ~/.ssh/*.config > ~/.ssh/config' | |
function jop { | |
ssh johannes.opper@$1 | |
} | |
function bet { | |
ssh betterplace@$1 | |
} | |
function spring_update_locales { | |
bx sping rake localeapp:update[$1] | |
} | |
function run_android_forwarding { | |
if [[ $(adb forward tcp:9222 localabstract:chrome_devtools_remote | tail -n1) == "" ]] | |
then | |
# open http://localhost:9222 | |
echo -e " \033[1;32m->\033[0m forwarding to localhost:9222" | |
else | |
echo -e " \033[1;31m->\033[0m failed to forward" | |
fi | |
} | |
alias ls='ls -G' | |
alias ll='ls -G -la' | |
alias watch_mysql='watch --interval=1 "mysql -uroot -e\"show processlist;\""' | |
alias mysql_stop='launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist' | |
alias mysql_start='launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist' | |
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh | |
function parse_git_dirty { | |
if [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] | |
then | |
echo -e "\033[1;32m +\033[0m" | |
else | |
echo -e "\033[1;32m -\033[0m" | |
fi | |
} | |
function parse_git_stash { | |
[[ $(git stash list 2> /dev/null | tail -n1) != "" ]] && echo -e " ->\033[1;33m stash\033[0m" | |
} | |
function current_git_branch { | |
echo $(__git_ps1 "%s") | |
# [[ $branch ]] && echo "($branch$(parse_git_dirty))" | |
} | |
function battery_charge { | |
# ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%d", $10/$5 * 100)}' | |
pmset -g batt | awk -F'[^0-9]*' '{print $3}' | tr -d '\n' | |
} | |
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi | |
set_prompt () { | |
local last_command=$? # Must come first! | |
PS1="" | |
local blue='\[\e[01;34m\]' | |
local white='\[\e[01;37m\]' | |
local red='\[\e[30;41m\]' | |
# local red='\[\e[01;31m\]' | |
local green='\[\e[30;42m\]' | |
# local green='\[\e[01;32m\]' | |
local yellow='\[\e[30;43m\]' | |
local reset='\[\e[00m\]' | |
local ground='⏚' | |
local charge=$(battery_charge) | |
local whoami=$(whoami) | |
local branch=$(current_git_branch) | |
# Add return code of last command | |
if [[ $last_command == 0 ]]; then | |
PS1+="$green$last_command " | |
else | |
PS1+="$red$last_command " | |
fi | |
# Add battery charge information | |
if [[ $charge -eq 100 ]]; then | |
PS1+="$green$ground " | |
elif [[ $charge -gt 30 ]]; then | |
PS1+="$yellow$ground " | |
else | |
PS1+="$red$ground ($charge)" | |
fi | |
if [[ $whoami != 'joe' ]]; then | |
PS1+="$yellow\u " | |
fi | |
PS1+="$reset " | |
# export PS1='\e[1;31m\u ▶\e[m@\h \e[0;32m\w\e[m $(parse_git_branch) $(parse_git_stash)\n $?> \e[1;31m31 \e[m \e[1;43m43\e[m\e[1;43m▶▶\e[m \e[30;43mhi intense\e[m' | |
# if [[ $EUID == 0 ]]; then | |
# PS1+="$red\\h " | |
# else | |
# PS1+="$green\\u@\\h " | |
# fi | |
# PS1+="$blue\\w \\\$$reset " | |
# Last_Command=$? # Must come first! | |
# Blue='\[\e[01;34m\]' | |
# White='\[\e[01;37m\]' | |
# Red='\[\e[01;31m\]' | |
# Green='\[\e[01;32m\]' | |
# Reset='\[\e[00m\]' | |
# FancyX='\342\234\227' | |
# Checkmark='\342\234\223' | |
# # Add a bright white exit status for the last command | |
# PS1="$White\$? " | |
# # If it was successful, print a green check mark. Otherwise, print | |
# # a red X. | |
# if [[ $Last_Command == 0 ]]; then | |
# PS1+="$Green$Checkmark " | |
# else | |
# PS1+="$Red$FancyX " | |
# fi | |
# # If root, just print the host in red. Otherwise, print the current user | |
# # and host in green. | |
# if [[ $EUID == 0 ]]; then | |
# PS1+="$Red\\h " | |
# else | |
# PS1+="$Green\\u@\\h " | |
# fi | |
# # Print the working directory and prompt marker in blue, and reset | |
# # the text color to the default. | |
# PS1+="$Blue\\w \\\$$Reset " | |
} | |
PROMPT_COMMAND='set_prompt' | |
# export PS1='\e[1;31m\u ▶\e[m@\h \e[0;32m\w\e[m $(parse_git_branch) $(parse_git_stash)\n $?> \e[1;31m31 \e[m \e[1;43m43\e[m\e[1;43m▶▶\e[m \e[30;43mhi intense\e[m' | |
colors() { | |
local fgc bgc vals seq0 | |
printf "Color escapes are %s\n" '\e[${value};...;${value}m' | |
printf "Values 30..37 are \e[33mforeground colors\e[m\n" | |
printf "Values 40..47 are \e[43mbackground colors\e[m\n" | |
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n" | |
# foreground colors | |
for fgc in {30..37}; do | |
# background colors | |
for bgc in {40..47}; do | |
fgc=${fgc#37} # white | |
bgc=${bgc#40} # black | |
vals="${fgc:+$fgc;}${bgc}" | |
vals=${vals%%;} | |
seq0="${vals:+\e[${vals}m}" | |
printf " %-9s" "${seq0:-(default)}" | |
printf " ${seq0}TEXT\e[m" | |
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m" | |
done | |
echo; echo | |
done | |
} | |
# Production settings | |
export RUBY_GC_HEAP_FREE_SLOTS=50000 # Ruby 2.1 | |
export RUBY_FREE_MIN=50000 | |
export RUBY_GC_HEAP_INIT_SLOTS=5000000 # Ruby 2.1 | |
export RUBY_HEAP_MIN_SLOTS=5000000 | |
export RUBY_GC_MALLOC_LIMIT=40000000 | |
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1.2 | |
export DEVELOPER=jop | |
export PARALLEL_TEST_PROCESSORS=4 | |
# /etc/profile.d/complete-hosts.sh | |
# Autocomplete Hostnames for SSH etc. | |
# by Jean-Sebastien Morisset (http://surniaulula.com/) | |
_complete_hosts () { | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
host_list=`{ | |
for c in /etc/ssh_config /etc/ssh/ssh_config ~/.ssh/config | |
do [ -r $c ] && sed -n -e 's/^Host[[:space:]]//p' -e 's/^[[:space:]]*HostName[[:space:]]//p' $c | |
done | |
for k in /etc/ssh_known_hosts /etc/ssh/ssh_known_hosts ~/.ssh/known_hosts | |
do [ -r $k ] && egrep -v '^[#\[]' $k|cut -f 1 -d ' '|sed -e 's/[,:].*//g' | |
done | |
sed -n -e 's/^[0-9][0-9\.]*//p' /etc/hosts; }|tr ' ' '\n'|grep -v '*'` | |
COMPREPLY=( $(compgen -W "${host_list}" -- $cur)) | |
return 0 | |
} | |
complete -F _complete_hosts ssh | |
complete -F _complete_hosts host | |
complete -F _complete_hosts jop | |
complete -F _complete_hosts bet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment