Skip to content

Instantly share code, notes, and snippets.

@JuanitoFatas
Created September 28, 2013 07:05
Show Gist options
  • Save JuanitoFatas/6739380 to your computer and use it in GitHub Desktop.
Save JuanitoFatas/6739380 to your computer and use it in GitHub Desktop.
my bash_profile
# Terminal Colour
export TERM=xterm-256color
export LSCOLORS="exfxcxdxbxegedabagacad"
export CLICOLOR=1
export LANG="zh_TW.utf-8"
export LC_ALL="zh_TW.utf-8"
# Set up Safari for development.
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write com.apple.Safari "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" -bool true
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
# Add RVM to PATH for scripting
export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig:$PKG_CONFIG_PATH"
export PATH=/Users/Mac/.local/bin:$PATH
export PATH=./bin:$PATH
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
# for homebrew
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
# CCL
export PATH=/usr/local/src/ccl/scripts:$PATH
if [ "${BASH-no}" != "no" ]; then
[ -r ~/.bashrc ] && source ~/.bashrc
fi
# homebrew tab completion
source `brew --prefix`/Library/Contributions/brew_bash_completion.sh
# Ruby GC Settings
export RUBY_HEAP_MIN_SLOTS=1250000
export RUBY_HEAP_SLOTS_INCREMENT=100000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=30000000
export RUBY_HEAP_FREE_MIN=12500
# Power
alias reboot="sudo shutdown -r now"
alias off="sudo shutdown -h now"
# My Alias
# Shell
alias cdd='cd ..'
alias cd~='cd ~'
alias psp='ps -auJuanito | grep'
alias pspr='ps -auJuanito | grep rails'
#copy the working directory into the clipboard
alias cwd='pwd | pbcopy'
alias src='source ~/.bash_profile'
# Ruby
alias g="gem"
alias b="bundle"
alias gemi="gem install"
alias bi="bundle install"
alias bu="bundle update"
alias bij8="bundle install -j8"
alias ri="rake install"
alias rip="rake install && pry"
# Rails
alias rbk='rake db:rollback'
alias mig='rake db:migrate'
alias migrate='rake db:migrate && rake db:test:prepare'
alias rails4000='rails s -p 4000'
alias restart='powder restart'
alias rails4000d='rails s -p 4000 -d'
alias railsc='rails c --sandbox'
alias rlp="rails r 'puts $:'"
# Git
alias gitcl='git clone'
alias gitst='git status'
alias gita='git add'
alias gitco='git checkout'
alias gitci='git commit'
alias gitp='git push'
alias gitch='git checkout'
alias gitpf='git push -u origin master'
alias gpum='git pull upstream master'
# RVM
alias rvmrc='touch .ruby-version .ruby-gemset'
alias rvmr='rvm reload'
alias rvml='rvm list'
alias rvmu='rvm use'
alias rvmi='rvm install'
alias rvmui='rvm uninstall'
alias rvmlk='rvm list known'
alias rvmgl='rvm gemset list'
alias rvmgd='rvm gemset delete'
alias rvmgc='rvm gemset create'
alias rvmgu='rvm gemset use'
alias rvmge='rvm gemset empty'
# Gem
alias ri='rake install'
alias rr='rake release'
# Ruby
alias rserv='ruby -run -e httpd . -p 8000'
# Vagrant
alias vg='vagrant'
# Python
alias pserv='python -m SimpleHTTPServer'
# Misc.
alias ql='qlmanage -p'
# =================== END of My Alias ===================
export PATH=/Applications/PLTSchemeV372/bin:$PATH
# Set the number of open files to be 1024
ulimit -s -n 1024
# bash-completion
[ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh
[ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh
# Git
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_since_last_commit {
now=`date +%s`;
last_commit=$(git log --pretty=format:%at -1 2> /dev/null) || return;
seconds_since_last_commit=$((now-last_commit));
minutes_since_last_commit=$((seconds_since_last_commit/60));
hours_since_last_commit=$((minutes_since_last_commit/60));
minutes_since_last_commit=$((minutes_since_last_commit%60));
echo "${hours_since_last_commit}h${minutes_since_last_commit}m ";
}
PS1="[\[\033[1;32m\]\w\[\033[0m\]] \[\033[0m\]\[\033[1;36m\]\$(git_branch)\[\033[0;33m\]\$(git_since_last_commit)\[\033[0m\]$ "
. ~/nvm/nvm.sh
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# Quick Navigate
export MARKPATH=$HOME/.marks
function jump {
cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1"
}
function mark {
mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1
}
function unmark {
rm -i $MARKPATH/$1
}
function marks {
ls -l $MARKPATH | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/ -/g' && echo
}
# change Bundler source
chsrc() {
case $1 in
help | --help | -h)
echo "tb, gz, thu or rubygems" && return;;
tb | taobao)
src='ruby.taobao.org';;
gz | gzruby)
src='gems.gzruby.org';;
thu | tsinghua)
src='mirrors.tuna.tsinghua.edu.cn/rubygems';;
*)
src='rubygems.org';;
esac
echo $src
res=`sed -E "s/^([ \\t]*)source[ \\t]*([\"'])http[^\"']+[\"']/\1source \2http:\/\/$src\2/" Gemfile`
echo $res > Gemfile
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment