Created
March 29, 2009 11:21
-
-
Save mattman/87359 to your computer and use it in GitHub Desktop.
.bashrc
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
# ----------- | |
# General | |
# ----------- | |
alias ..='cd ..' | |
alias ll='ls -lh' | |
alias la='ls -la' | |
alias ps='ps -ax' | |
alias du='du -hc' | |
alias cd..='cd ..' | |
alias today='date +"%A, %B %d, %Y"' | |
alias yest='date -v-1d +"%A %B %d, %Y"' | |
alias recent='ls -lAt | head' | |
alias ebashrc='mate ~/.bashrc' | |
alias mbashrc='mate ~/.bashrc' | |
alias sbashrc='source ~/.bashrc' | |
# ------------- | |
# Shortcuts | |
# ------------- | |
alias c="clear" | |
alias m="mate" | |
# ------- | |
# Git | |
# ------- | |
alias ga='git add' | |
alias gs='git status' | |
alias gd='git diff' | |
alias github="open \`git config -l | grep 'remote.origin.url' | sed -En 's/remote.origin.url=git(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\3\/\4/p'\`" | |
# --------- | |
# Rails | |
# --------- | |
alias gemi='sudo gem install --no-rdoc --no-ri' | |
alias sg='script/generate' | |
alias ss='script/server' | |
alias sc='script/console' | |
alias sl='open http://localhost:3000' | |
alias mig='rake db:migrate db:test:prepare' | |
alias allspecs='spec -fs -c spec' | |
alias preptest='rake db:migrate db:test:prepare && rake RAILS_ENV=test ts:config ts:start ts:in' | |
# --------------- | |
# Environment | |
# --------------- | |
export PATH="$PATH:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin" | |
export PATH="$HOME/bin/:$PATH" | |
export HISTSIZE=10000 | |
export HISTFILESIZE=10000 | |
export PAGER=less | |
export CLICOLOR=1 | |
export EDITOR="/usr/bin/mate -w" | |
# --------- | |
# Prompt | |
# --------- | |
git_prompt_info() { | |
branch_prompt=$(__git_ps1) | |
if [ -n "$branch_prompt" ]; then | |
status_icon=$(git_dirty) | |
echo $branch_prompt $status_icon | |
fi | |
} | |
# Show character if changes are pending | |
git_status() { | |
if git status | grep 'to be commit' > /dev/null; then | |
echo "☠" | |
fi | |
} | |
git_dirty() { | |
git st 2>/dev/null | wc -l | awk '{if ($1 > 2) print "☠"}' | |
} | |
function prompt { | |
local BLACK="\[\033[0;30m\]" | |
local RED="\[\033[0;31m\]" | |
local GREEN="\[\033[0;32m\]" | |
local YELLOW="\[\033[0;33m\]" | |
local BLUE="\[\033[0;34m\]" | |
local PURPLE="\[\033[0;35m\]" | |
local CYAN="\[\033[0;36m\]" | |
local WHITE="\[\033[0;37m\]" | |
local WHITEBOLD="\[\033[1;37m\]" | |
export PS1="${CYAN}\w${GREEN} \$(git_prompt_info)${WHITE} \$ " | |
} | |
prompt | |
# ------------------ | |
# Autocompletes | |
# ------------------ | |
complete -C ~/rake_complete.rb -o default rake | |
complete -C ~/cap_complete.rb -o default cap | |
# --------- | |
# Other | |
# --------- | |
# Cool History Summerizer | |
historyawk(){ history|awk '{a[$2]++}END{for(i in a){printf"%5d\t%s\n",a[i],i}}'|sort -nr|head; } | |
# cd directly to a dir and list contents | |
cdl() { | |
if [ "$1" ] | |
then builtin cd "$1" && ll | |
else builtin cd && ll | |
fi | |
} | |
function nth { | |
osascript -e " | |
Tell application \"Terminal\" | |
activate | |
tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down | |
do script with command \"cd '$(pwd)'; clear\" in selected tab of the front window | |
end tell" | |
} | |
_mategem() | |
{ | |
local curw | |
COMPREPLY=() | |
curw=${COMP_WORDS[COMP_CWORD]} | |
local gems="$(gem environment gemdir)/gems" | |
COMPREPLY=($(compgen -W '$(ls $gems)' -- $curw)); | |
return 0 | |
} | |
complete -F _mategem -o dirnames mategem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment