Created
September 24, 2010 08:02
-
-
Save subblue/595024 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
# Command Enhancements | |
# Utility | |
alias reload='source ~/bin/dotfiles/bash/aliases' | |
alias ea='mate -w ~/bin/dotfiles/bash/aliases && reload' # Edit aliases | |
alias ee="mate ~/bin/dotfiles/bash/env" | |
alias eb="mate ~/bin" | |
# Quicker cd | |
alias cg='cd /Library/Ruby/Gems/1.8/gems/' | |
function cr() { | |
cd ~/repos/$* | |
} | |
function cdc() { | |
cd $1; ls | |
} | |
function cdw() { | |
cd ~/Websites/$1 | |
} | |
alias c='clear' | |
alias cl='clear; l' | |
alias cls='clear; ls' | |
alias h='history' | |
alias hf="history | grep " | |
alias a='ls -A' # -A all except literal . .. | |
alias la="ls -A -l -G" | |
alias l.='ls -d .[^.]*' | |
alias l='ls -lhGt' # -l long listing, most recent first | |
# -G color | |
alias lh="ls -lh" | |
alias ll='ls -lhG' # -l long listing, human readable, no group info | |
alias lt='ls -lt' # sort with recently modified first | |
alias md='mkdir -p' | |
alias cp='cp -i' | |
alias rm='rm -i' | |
alias mv='mv -iv' | |
alias cdd='cd -' # goto last dir cd'ed from | |
alias ..='cd ..' # up one dir | |
alias grep='GREP_COLOR="1;37;41" LANG=C grep --color=auto' | |
function take() { | |
mkdir -p "$1" | |
cd "$1" | |
} | |
alias e='exit' | |
alias k9="killall -9" | |
function killnamed () { | |
ps ax | grep $1 | cut -d ' ' -f 2 | xargs kill | |
} | |
function zipr() { | |
zip -r $1.zip $1 | |
} | |
# Finder | |
alias o='open . &' | |
alias ff='open -a Firefox' | |
# Processes | |
alias tu='top -o cpu' # cpu | |
alias tm='top -o vsize' # memory | |
# Git | |
alias ungit="find . -name '.git' -exec rm -rf {} \;" | |
alias gb='git branch' | |
alias gba='git branch -a' | |
alias gc='git commit -v' | |
alias gca='git commit -v -a' | |
# Commit pending changes and quote all args as message | |
function gg() { | |
git commit -v -a -m "$*" | |
} | |
alias gco='git checkout' | |
alias gd='git diff' | |
alias gdm='git diff master' | |
alias gl='git pull' | |
alias gnp="git-notpushed" | |
alias gp='git push' | |
alias gst='git status' | |
alias gt='git status' | |
alias g='git status' | |
alias eg='mate .git/config' | |
# Git clone from GitHub | |
function gch() { | |
git clone git://github.com/$USER/$1.git | |
} | |
# Setup a tracking branch from [remote] [branch_name] | |
function gbt() { | |
git branch --track $2 $1/$2 && git checkout $2 | |
} | |
# Quickly clobber a file and checkout | |
function grf() { | |
rm $1 | |
git checkout $1 | |
} | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" | |
} | |
source ~/bin/dotfiles/misc/git-completion.bash | |
# SVN | |
alias upw="gitit && cd ~ && svn up Websites/2.0/ Websites/vendor/ Websites/1.4/ Websites/projects/" | |
function svnrm() { | |
rm -rf `find . -type d -name .svn` | |
} | |
# MySQL | |
alias mysql='mysql -uroot -p --default-character-set=utf8' | |
alias mysqladmin='mysqladmin -uroot -p --default-character-set=utf8' | |
alias mysqldump='mysqldump -uroot -p --default-character-set=utf8' | |
# Text editing | |
# TextMate | |
alias et="mate" | |
alias ett="mate ." | |
alias m="mate ." | |
alias etr="mate app config lib db schema public spec test vendor/gems vendor/plugins Rakefile Capfile Vladfile Todofile README stories merb slices tasks features &" | |
_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 | |
# Ruby | |
alias r="rake" | |
function markdown() { | |
/Applications/TextMate.app/Contents/SharedSupport/Support/bin/Markdown.pl $1 > $1.html | |
} | |
#source ~/bin/ruby_switcher.sh | |
# if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi | |
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm | |
# Rails | |
alias rp='touch tmp/restart.txt' | |
alias sc='./script/console' | |
alias sg='./script/generate' | |
alias sp='./script/plugin' | |
alias ss='./script/server --debugger' | |
alias ss2='./script/server -p3001 --debugger' | |
alias tl='tail -f log/*.log' | |
alias ts='thin start' | |
alias autot='AUTOFEATURE=true bundle exec autotest' | |
function scap() { | |
cap $1 --set deploy_environment='staging' | |
} | |
# TDD / BDD | |
alias aa='autotest' | |
alias aaf='autotest -f' # Don't run all at start | |
alias aas="./script/autospec" | |
alias sss="./rake spec:server:start" | |
# Setup a tunnel | |
function haproxyssh() { | |
ssh -L7997:127.0.0.1:7997 deploy@$1.com | |
} | |
function tunnel() { | |
ssh -v -nNT -g -R *:$1:0.0.0.0:3000 $2 | |
} | |
# Syntax check Javascript | |
function jsc() { | |
jsl -conf /etc/jsl/jsl.conf -process $1 | |
} | |
function aiff2mp3() { | |
lame -h -V 0 $1.aif $1.mp3 | |
} | |
function wav2mp3() { | |
lame -h -V 0 $1.wav $1.mp3 | |
} | |
# XCode | |
# Analyze release build | |
alias sx="xcodebuild clean && ~/src/checker-0.146/scan-build -k -V xcodebuild" | |
# Analyze test build | |
alias sxt="xcodebuild -target Test clean && ~/src/checker-0.146/scan-build -k -V xcodebuild -target Test" | |
# Call with -target Foo | |
function sxx() { | |
xcodebuild $* clean && ~/src/checker-0.146/scan-build -k -V xcodebuild $* | |
} | |
alias ox="open *.xcodeproj" | |
# Nginx | |
function nginx_stop() { | |
ps ax | grep nginx | cut -d " " -f 1 | xargs sudo kill -9 | |
} | |
function nginx_start() { | |
sudo /opt/nginx/sbin/nginx | |
} | |
# TaskPaper | |
function new-tp() { | |
touch $1.taskpaper | |
open $1.taskpaper | |
} | |
# From http://github.com/suztomo/dotfiles | |
function rmf() { | |
for file in $* | |
do | |
__rm_single_file $file | |
done | |
} | |
function __rm_single_file() { | |
if ! [ -d ~/.Trash/ ] | |
then | |
command /bin/mkdir ~/.Trash | |
fi | |
if ! [ $# -eq 1 ] | |
then | |
echo "__rm_single_file: 1 argument required but $# passed." | |
exit | |
fi | |
if [ -e $1 ] | |
then | |
BASENAME=`basename $1` | |
NAME=$BASENAME | |
COUNT=0 | |
while [ -e ~/.Trash/$NAME ] | |
do | |
COUNT=$(($COUNT+1)) | |
NAME="$BASENAME.$COUNT" | |
done | |
command /bin/mv $1 ~/.Trash/$NAME | |
else | |
echo "No such file or directory: $file" | |
fi | |
} | |
# Misc | |
alias dnsf="dscacheutil -flushcache" | |
function num_files() { | |
for t in files links directories; do echo `find . -type ${t:0:1} | wc -l` $t; done 2> /dev/null | |
} | |
shopt -s histappend | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment