Skip to content

Instantly share code, notes, and snippets.

@ariejan
Created April 21, 2010 09:35
Show Gist options
  • Save ariejan/373622 to your computer and use it in GitHub Desktop.
Save ariejan/373622 to your computer and use it in GitHub Desktop.
# Use MacPorts, least priority
# For the amazon-ec2 gem
export EC2_URL="https://eu-west-1.ec2.amazonaws.com"
# jEdit with large memory allocation
alias jedit='java -Xms512m -Xmx1024m -jar /Applications/jEdit.app/Contents/Resources/Java/jedit.jar'
## export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export PATH=/Users/ariejan/.homebrew/bin:/opt/local/bin:/opt/local/sbin:$PATH:/usr/local/bin:/usr/local/sbin
export DISPLAY=:0.0
# Always enable AUTOFEATURE
export AUTOFEATURE=true
ajgs(){
URL=$1
SHORT_URL=`curl -s -d "url=$URL&api_key=xxx" http://aj.gs/api/add`
echo $SHORT_URL | pbcopy
echo "-- $URL => $SHORT_URL"
}
# Start the GPG Agent
# gpg-agent --daemon --use-standard-socket 2&>1 /dev/null
# Editors
export EDITOR='/opt/local/bin/mate -w'
export SVN_EDITOR='vim'
export HISTSIZE=10000
shopt -s histappend # Append to $HISTFILE, dont overwrite
PROMPT_COMMAND='history -a'
# Create a /tmp/mysql.sock socket
ln -sf `mysql_config5 --socket` /tmp/mysql.sock
# ssh autocompletion
SSH_COMPLETE=( $(cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
uniq | \
egrep -v [0123456789]) )
complete -o default -W "${SSH_COMPLETE[*]}" ssh
# Java's
alias set_java5='export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home'
alias set_java6='export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home'
set_java6
# alias tr='touch tmp/restart.txt'
alias r3='rvm use 1.8.7@rails3'
alias r2='rvm use 1.8.7'
#### General
alias ra='cd ~/rails/'
alias home='cd ~'
alias l='ls -lahG'
alias h='history'
alias c='clear'
alias ..='cd ..'
alias ...='cd ../..'
alias ebash='mate ~/.profile &' # because i edit my bash_profile a lot with new things
alias rbash='source ~/.profile' # same as previous, after editing you have to source it for the new stuff to work
alias his='history | grep -i $1'
#### Git
alias g='git'
alias gs='git status'
alias gst='git stash'
alias gb='git branch'
alias gba='git branch -a'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gd='git diff | mate'
alias gl='git pull'
alias gp='git push'
alias gqf='git commit -a -m "Quick Fix™" && git push && cap deploy:update && cap deploy:restart'
alias git_first_push='git push origin master:refs/heads/master'
alias glg='git lg'
grip(){
find . -name $1 -exec grep -H "$2" {} \;
}
# Remove all deleted files from the Git repository
grm(){
git status | grep "deleted:" | awk '{print $3}' | xargs git rm --ignore-unmatch
}
mysql_tunnel(){
if [ $# == 2 ]; then
PORT=$2
else
PORT="8888"
fi
echo "SSH Tunnel to $1:3306 on 127.0.0.1:$PORT"
echo "Press CTRL-C to close"
ssh -N $1 -L $PORT:127.0.0.1:3306
}
#### Rails
function cdra {
cd ~/rails/$1*
}
function cdgem {
cd $GEM_HOME/gems; cd `ls|grep $1|sort|tail -1`
}
# alias irb='irb --readline -r irb/completion -rubygems' # use readline, completion and require rubygems by default for irb
function ipsum {
lorem 5 paragraphs | pbcopy
}
# MRI Ruby
alias ss='./script/server thin' # start up the beast
alias sc='script/console' # obvious
alias a='autospec' # makes autotesting even quicker
alias sr='./script/rails' # Rails 3 love
alias cov='rake spec:rcov && open coverage/index.html' # Generate coverage and open it
#### TextMate
alias e='mate . &' #open current dir
alias et='mate .gitignore .gitmodules CHANGELOG README README.textile Rakefile app/ config/ db/ doc/ features/ lang/ lib/ public/ test/ vendor/ spec/ script/ stories/ &'
function r(){
cdra $1; et
}
#copy pub key
function setupkeys {
if [[ -z "$1" ]]; then
echo "!! You need to enter a hostname in order to send your public key !!"
else
echo "* Copying SSH public key to server..."
ssh ${1} "mkdir -p ~/.ssh && cat - >> ~/.ssh/authorized_keys" < ~/.ssh/id_rsa.pub
echo "* All done!"
fi
}
# Move to Ariejan.net
function upaj {
if [[ -z "$1" ]]; then
echo "!! You ned to specify a filename to upload to Ariejan.net"
else
scp ${1} [email protected]:/root
fi
}
#GIT and SVN hacks
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
# ϟ ☠ ⁕ ⁙ ⁘ ⁜ ↂ ⇪ ⊕ ⊗ ⊙ ⊡ ⌘ ⌖ ⌦ ⌫ ⌽ ⎈ ⎇ ⎋ ⎚ ⏏ ⏎ ◈ ◉ ☀ ☁ ☂ ☃ ★ ☆ ☕ ☢ ☣ ☭ ☮ ☯ ♨ ♠ ♿ ✈ ✎ ❉ ⟁
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo " ϟ"
}
# Prompt
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
DULL=0
BRIGHT=1
FG_BLACK=30
FG_RED=31
FG_GREEN=32
FG_YELLOW=33
FG_BLUE=34
FG_VIOLET=35
FG_CYAN=36
FG_WHITE=37
FG_NULL=00
BG_BLACK=40
BG_RED=41
BG_GREEN=42
BG_YELLOW=43
BG_BLUE=44
BG_VIOLET=45
BG_CYAN=46
BG_WHITE=47
BG_NULL=00
##
# ANSI Escape Commands
##
ESC="\033"
NORMAL="\[$ESC[m\]"
RESET="\[$ESC[${DULL};${FG_WHITE};${BG_NULL}m\]"
##
# Shortcuts for Colored Text ( Bright and FG Only )
##
# DULL TEXT
BLACK="\[$ESC[${DULL};${FG_BLACK}m\]"
RED="\[$ESC[${DULL};${FG_RED}m\]"
GREEN="\[$ESC[${DULL};${FG_GREEN}m\]"
YELLOW="\[$ESC[${DULL};${FG_YELLOW}m\]"
BLUE="\[$ESC[${DULL};${FG_BLUE}m\]"
VIOLET="\[$ESC[${DULL};${FG_VIOLET}m\]"
CYAN="\[$ESC[${DULL};${FG_CYAN}m\]"
WHITE="\[$ESC[${DULL};${FG_WHITE}m\]"
# BRIGHT TEXT
BRIGHT_BLACK="\[$ESC[${BRIGHT};${FG_BLACK}m\]"
BRIGHT_RED="\[$ESC[${BRIGHT};${FG_RED}m\]"
BRIGHT_GREEN="\[$ESC[${BRIGHT};${FG_GREEN}m\]"
BRIGHT_YELLOW="\[$ESC[${BRIGHT};${FG_YELLOW}m\]"
BRIGHT_BLUE="\[$ESC[${BRIGHT};${FG_BLUE}m\]"
BRIGHT_VIOLET="\[$ESC[${BRIGHT};${FG_VIOLET}m\]"
BRIGHT_CYAN="\[$ESC[${BRIGHT};${FG_CYAN}m\]"
BRIGHT_WHITE="\[$ESC[${BRIGHT};${FG_WHITE}m\]"
# REV TEXT as an example
REV_CYAN="\[$ESC[${DULL};${BG_WHITE};${BG_CYAN}m\]"
REV_RED="\[$ESC[${DULL};${FG_YELLOW}; ${BG_RED}m\]"
export PS1="$RED\w$YELLOW \$(parse_git_branch) $WHITE\$ "
# MacPorts Installer addition on 2008-12-31_at_16:46:54: adding an appropriate MANPATH variable for use with MacPorts.
export MANPATH=/opt/local/share/man:$MANPATH
# RVM
if [[ -s /Users/ariejan/.rvm/scripts/rvm ]] ; then source /Users/ariejan/.rvm/scripts/rvm ; fi
rvm use 1.8.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment